relation « Load « JPA Q&A





1. Why doesn't JPA offer a loadChildren() method for lazily loaded relations?    stackoverflow.com

There are times when I want to define a relationship as being lazily loaded, since 90% of the time I don't want the child entities, yet also have the possibility of ...

2. Is it possible to use lazy loading with many to many relation in hibernate?    stackoverflow.com

hi i have two entities User and Authority they have many to many relation:

@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinTable(name = "user_role", joinColumns = { @JoinColumn(name = "user_id") }, ...

3. Cache issue with eagerly loaded relation    forum.hibernate.org

I have the following classes: Party Code: @Entity @Table(name = "Party") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class Party implements Serializable { private static final long serialVersionUID = 1L; private String name; private long version; private long id; public String getName() { ...

5. Loading one-to-many relation objects    forum.hibernate.org

I assume that in your mapping file for Order contains a collection or sorts to hold the UnitDetails objects and assuming you are using Hibernate 3. Using HQL: session.createQuery("select o from Orders as o fetch join o.unitDetails").list() Using CriteriaAPI: session.createCriteria(Orders.class).setFetchMode("unitDetails", FetchMode.JOIN).list(); By default you should not enable join fetching in the mapping file for those cases where you want to lazy ...

6. How to load an Parent Object in a key-many-to-one relation?    forum.hibernate.org

Hi, I would like to know what is the best way to get the data (initialize an object) from a key-many-to-one relationship. I found some problem to get data from an object in a many-to-one relationship using the key-many-to-one tag. I have theses 2 tables linked by a many-to-one relationship: AstAccountRetail have theses primary keys (composite-key) : ossAccount, astSubAccount and ossPlanType. ...

7. Needed a relation loaded only when access    forum.hibernate.org

I am not able to get a associated object to be NOT loaded together with the main object. In this regard is different from and . Hibernate version: 3.05 Mapping documents:

8. Child entities also getting loaded for many-to-one relations    forum.hibernate.org

DetachedCriteria mpltyCriteria = DetachedCriteria.forClass( Municipality.class, "mplty" ); mpltyCriteria.add( Restrictions.eq( "mplty.id", new Long( 1 ) ) ); mpltyCriteria.setProjection( Projections.property( "mplty.id" ) ); DetachedCriteria streetCriteria = DetachedCriteria.forClass( Street.class, "mystreet" ); streetCriteria.add( Property.forName( "mystreet.MuncipalityIDColumnINStreet" ).in( mc ) ); streetCriteria.addOrder( Order.asc( "mystreet.MuncipalityIDColumnINStreet" ) ); streetCriteria.setFirstResult( page ); streetCriteria.setMaxResults( 100 ); streetCriteria.setResultTransformer( Criteria.DISTINCT_ROOT_ENTITY ); List results = streetCriteria.getExecutableCriteria( session ).list();

9. Nullable many-to-one relation prevents lazy loading    forum.hibernate.org

Hibernate version: 3.2.4 Name and version of the database you are using: Oracle 10gR2 I have the following mappings (actual names changed): Parent table: Code: ...