Hey Folks,
i've a problem using the @loader annotation on a @OneToMany. As it looks like from the log, at least the row is found through the query but the collection stays null.
I searched the web a lot, but didn't found things, that were really helping. Maybe you have an idea?
thanks a lot :9
Code:
14:52:26,765 DEBUG ConcurrentStatisticsImpl:411 - HHH000117: HQL: SELECT * FROM impact_study impStud WHERE impStud.Study_id = ?, time: 15ms, rows: 1
14:52:26,770 TRACE SessionImpl:1367 - Setting flush mode to: AUTO
14:52:26,771 TRACE DefaultInitializeCollectionEventListener:83 - Collection initialized
Exception in thread "main" java.lang.NullPointerException
at org.hibernate.collection.internal.PersistentBag.size(PersistentBag.java:242)
at com.bayer.sam.parser.sam.help.Blub.main(Blub.java:28)
Code:
@NamedNativeQuery(name = "loadImpStudyByID",
query = "SELECT * FROM impact_study impStud WHERE impStud.Study_id = ?", resultClass=ImpactStudy.class)
public class SamStudy extends SamEntity implements Serializable {
.......
@OneToMany(fetch=FetchType.LAZY)
@Loader(namedQuery="loadImpStudyByID")
private Collection<ImpactStudy> mImpactStudy = new ArrayList<ImpactStudy>();
Code:
@Table(name = "impact_study")
public class ImpactStudy implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = ImpactParser.studyId)
private Integer studyNo;