Selecting a fetch strategy for Hibernate that a property or component should be lazy loaded through interception. To disable proxies and enable interception for associations with annotations, you have to rely on a Hibernate extension: @ManyToOne @JoinColumn(name=”SELLER_ID”, nullable = false, updatable = false) @org.hibernate.annotations.LazyToOne( org.hibernate.annotations.LazyToOneOption.NO_PROXY ) private User seller; To enable interception, the bytecode of your classes must be instrumented after compilation, before runtime. Hibernate provides an Ant task for that purpose: We leave it up to you if you want to utilize interception for lazy loading in our experience, good use cases are rare. Naturally, you not only want to define what part of your persistent object network must be loaded, but also how these objects are retrieved. In addition to creating a fetch plan, you want to optimize it with the right fetching strategies. 13.2 Selecting a fetch strategy Hibernate executes SQL SELECT statements to load objects into memory. If you load an object, a single or several SELECTs are executed, depending on the number of tables which are involved and the fetching strategy you ve applied. Your goal is to minimize the number of SQL statements and to simplify the SQL statements, so that querying can be as efficient as possible. You do this by applying the best fetching strategy for each collection or association. Let s walk through the different options step by step.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.
This entry was posted
on Saturday, January 26th, 2008 at 12:09 am and is filed under j2ee.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.