I'm really new in the community (and in Hibernate also) so I may be infringing some rule while responding to a 2011 question or saying something incorrect.
I faced exactly the same problem. In my situation I had an elementcollection, eagerly loaded, in a class A with an Id association with another class B identified by a composite-id. The columns of B composite id were used in the joinColumns collection of A elementCollection attribute. When invoking buildSessionFactory, NPE was thrown. After debugging the org.hibernate.loader.entity.EntityLoader.<init> code, I detected while reading a code comment, that the eagerly property was the problem (I still don't understand why) because the function of the NPE is only invoked if eager is used.
The code comment is "// for each association with a composite id containing key-many-to-one(s), find the bidirectional side of // each key-many-to-one (if exists) to see if it is eager as well. If so, we need to track the indices", in file org.hibernate.loader.entity.EntityJoinWalker.
So to fix the problem, I removed the eager annotation of the elementCollection, and simulated it through accesing the attribute while the transaction is opened in the DAO.
EDIT: This happens to me in version 4.1.4-Final.
|