Lazy « Map « JPA Q&A





1. Hibernate XML Mapping: Lazy False or Fetch Select?    stackoverflow.com

I have a simple question. I found this Hibernate config on our project:

<many-to-one name="employee" 
    class="com.myapp.Employee"
    cascade="merge"
    lazy="false"
    fetch="select">
<column ...

2. HQL lazy="false"    stackoverflow.com

I am doing a query using HQL. As for now it is set with

<set name="childRules" table="MyRule" lazy="false" sort="natural" inverse="true" cascade="delete">
 <key column="parentId"/>
 <one-to-many class="rule.MyRule" />
</set>
The query is like this:
<query ...

5. Why hibernate fetches lazy mapped entities?    forum.hibernate.org

Author Message JonnyRico Post subject: Why hibernate fetches lazy mapped entities? Posted: Fri Jul 02, 2010 9:56 am Beginner Joined: Wed Mar 03, 2010 4:06 am Posts: 21 Hi, I have a m:n relationship between customers and accounts: This relationship is resolved in another table customer_accounts. The mapping looks like this: Code: @Entity @Table(name = "customer") public class Customer ...

6. Lazy Parent-Child relationships    forum.hibernate.org

Hello, I have a question about Lazy Parent-Child relationships. I've read chapter 8 several times and searched the forum but I come up empty. This question applies to Hibernate 2.0. We have a series of relationships: Category -> SubCategory -> SubSubCategory -> Part We have them setup with lazy initialization between the sets. Our DAO has methods to return Lists of ...

7. Very Lazy Maps    forum.hibernate.org

I'm having some performance issues with maps. Lets say I have a class User with a map collection. That collection maps to a class Foo. For each User, there might be thousands of Foos, but I only need a few at a certain time. What would be ideal is that whenever I call Map.get it checks to see if it had ...

8. Hibernate initializes lazy collection during INSERT of child    forum.hibernate.org

I have a simple one-to-many relationship. When I insert child record for a parent, hibernate initializes the lazy collection for the parent. Even though there is no change in the parent attributes. The lazy collection should not initialize. This is big performance issue as the performance degrades if there are more children for the parent. Any help to overcome/resolve this issue? ...

9. lazy mapping is not lazy    forum.hibernate.org

Hi, I have the code below in my program with the corresponding mapping docs below. The problem I have is that when retrieving the list of account objects, for each account hibernate queries the corresponding contact object. I do not wish the contacts to be initialized when I retrieve the acccounts (so an outer join would not work for me. I ...





10. How-to on lazy one-to-one mapping?    forum.hibernate.org

I have two classes and tables as defined below: Code: class A { B b; String name; getB(); setB(); } class B { A a; getA(); getB(); } table_a { ...

11. lazy, not constrained, many-to-one or one-to-one mapping    forum.hibernate.org

Is there any way to create a not constrained many-to-one mapping which is lazy? It is not very effecient (or pretty) to catch ObjectNotFound exceptions throughout our code, and we have several relations which are not constrained by foreign keys (and thus may not exist). I don't know how to do this, but I was thinking that if a direct relation ...

13. Overriding lazy    forum.hibernate.org

14. Overriding non-lazy instantiation via code    forum.hibernate.org

We've got a set of mapping files setup with *no* lazy-instantiation. As noted in the docs, this is the easy way to avoid problems with querying on associated objects after a session has closed and has worked well so far while we're getting the system built and not focused on performance. Later we are planning to shift everything to lazy-instantiated in ...

15. Mapping files and lazy instantiation of relationships.    forum.hibernate.org

My question is more about practice and how to implement rather than a specific question. I'm using hibernate with the Spring framework. I have an object which forms the root of an object graph. This Event object maps to a table in Oracle. Triggers populate this "event" table with information about what has happend in a work flow. When an event ...

16. How to make a one-to-one mapping lazy?    forum.hibernate.org

I've got a one-to-one mapping in a class that gets loaded for every page load. The class that it's mapped to is used just about never, so naturally I would like to have that class lazy loaded. However, no matter what I do I get a SELECT issued on every pageload, even though both tables are . Does anyone ...





17. Half-lazy collection mappings; read-only class mappings    forum.hibernate.org

Hibernate version: 3.0.5 I have two classes, A and B, which have a many-to-many relationship to each other on a join table. They are mapped and work fine. The relationship is mapped lazily, so when I call A.getBs() and iterate over the resulting collection, I get n+1 selects. I get the impression that this is the expected behaviour from the FAQ, ...

18. Criteria Query on one to many mapping and lazy initializatio    forum.hibernate.org

Newbie Joined: Sun Dec 11, 2005 10:17 am Posts: 1 My class RequestBean has one to many mapping with BalanceCertificate Class.I have one to many declartion in the hbm xml of RequestBean.The query is reurning one row.But when i load the object that is mapped in lazy i returns two rows for that collection.The criteria that was applied to the query ...

19. one-to-one mapping and lazy association - cant they coexist?    forum.hibernate.org

Hibernate version: 3.0.5 mapping documents: s_request_seq

20. Make mapping as lazy in Hibernate 2.0    forum.hibernate.org

21. ManyToOne lazy fetching on non primary key associations    forum.hibernate.org

This topic should be named a little bit more correctly: instead of: "ManyToOne lazy fetching on non primary key associations" something like: "ManyToOne lazy fetching of properties referring to non-@Id properties" Though the original title is okay. I just wanted to communicate what I found: I created two tables, free from any primary/foreign key constraints - and lazy fetching still works ...

22. put() fails on lazy one-to-many Map    forum.hibernate.org

Author Message gzhuli Post subject: put() fails on lazy one-to-many Map Posted: Thu Nov 02, 2006 7:25 am Newbie Joined: Thu Nov 02, 2006 6:20 am Posts: 2 Hello, Recently I'm moving my application from Hibernate 3.2.0CR2 to 3.2.0GA, but something's broken. I have two classes, Document and DocumentHistory. Document references its history snapshots through a one-to-many Map to ...

23. lazy="false" in class mappings    forum.hibernate.org

Hi, If I use lazy="false" in class mappings (), can I overrite it when mapping associations to this class or with criteria queries and Fetch Modes? Because the documentation (in chapter 5.1.3. class) says: "lazy (optional): Lazy fetching may be completely disabled by setting lazy="false". Hibernate version: 3.0 Thanks

24. ManyToMany lazy problem    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.3.0 Hi, When I run my applications test I get the following exception: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.telvent.padron.bi.territorio.model.Consulado.paises, no session or session was closed at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358) at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:249) at com.telvent.padron.bi.territorio.service.ConsuladoService.saveConsulado(ConsuladoService.java:109) at com.telvent.padron.bi.territorio.service.ConsuladoService$$FastClassByCGLIB$$c70548f1.invoke() at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:675) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154) ...

25. Overriding lazy when using FetchMode.SELECT    forum.hibernate.org

Why is there the ability to use lazy="false" and fetch="select" in the mapping, but not in the Criteria API. For example, if I have lazy="proxy" and fetch="select", why can't I call criteria.setLazy on the association so that it will behave exactly as if I had lazy="false" and fetch="select", but just for that Criteria? Criteria.setFetchMode does not help me. I do not ...

26. lazy fetching an association mapped as non-lazy    forum.hibernate.org

I have an entity (parent) with a series of child associations mapped as sets. Each of these associations is NOT mapped as lazy (ie. as proxy or eager - I have a mapping file with default-lazy="false") So my default load behaviour pulls up the parent object with all of its child associations eagerly fetched, which is how I want it. Now ...

27. mapping a lazy init many-to-many associtation    forum.hibernate.org

Hi, Here a short description of my problem. I have 2 entities named Tag and Seller. A tag has list of sellers and a seller has a list of tag. And I mapped this to a many-to-many association and everything is ok until now. Where I get an tag object all sellers are also retrieved, which is ok. But I don't ...

28. problem with extra-lazy map    forum.hibernate.org

Newbie Joined: Sun Oct 05, 2008 11:29 am Posts: 9 Hi I have a User object, that have some details, a list of it's friends, and invert list of friends (friends of him). When I config the lists to be lazy, it's work fine, but when I set it to be extra-lazy, I get "Column 'FriendId' not found" exception. Hibernate version: ...

29. Children collection initialized and lazy=true    forum.hibernate.org

Newbie Joined: Tue Mar 24, 2009 4:30 pm Posts: 5 Hi, First of all, I'm trying to persist hierarchical data via hibernate. I have a class, AbstractHierarchy that has a collection of children, also of type AbstractHierarchy. There are two concrete subclasses of this, ConcreteHierarchy1 and ConcreteHierarchy2. Which one is instantiated depends on a discriminator value. I'm having a problem where ...

30. Children collection initialized and lazy=true    forum.hibernate.org

Newbie Joined: Tue Mar 24, 2009 4:30 pm Posts: 5 Hi, First of all, I'm trying to persist hierarchical data via hibernate. I have a class, AbstractHierarchy that has a collection of children, also of type AbstractHierarchy. There are two concrete subclasses of this, ConcreteHierarchy1 and ConcreteHierarchy2. Which one is instantiated depends on a discriminator value. I'm having a problem where ...

31. Children collection initialized and lazy=true    forum.hibernate.org

Newbie Joined: Tue Mar 24, 2009 4:30 pm Posts: 5 Hi, First of all, I'm trying to persist hierarchical data via hibernate. I have a class, AbstractHierarchy that has a collection of children, also of type AbstractHierarchy. There are two concrete subclasses of this, ConcreteHierarchy1 and ConcreteHierarchy2. Which one is instantiated depends on a discriminator value. I'm having a problem where ...

32. any mapping with lazy fetching    forum.hibernate.org

I have one class A which have a property with any mapping. My problem is that hibernate does not initialize my sender object. It seems like hibernate does not read my lazy="false". Is ...

33. Programmatically overriding lazy for collections    forum.hibernate.org

Newbie Joined: Fri Aug 28, 2009 12:50 pm Posts: 5 My team has run into an issue programmatically overriding the "lazy" attribute specified in our Hibernate mapping files for collections. Some background info: Our application originally used a Versant object database, and we have converted our application to use Hibernate 3.1.3 to persist our data into MySQL 5.1.30-community. We are currently ...