|
Trying to load the entities of a @OneToMany relation with the @Loader annotation and a @NamedNativeQuery causes a NullPointerException when the PersistentSet is accessed for the first time:
PersistentSet.iterator() line: 181
Example:
@Entity @Table(name = "ROOT_ENTITY") @NamedNativeQuery(name="loadChildEntities", query="select * from CHILD_ENTITY c where c.PARENT = ?", resultClass=ChildEntity.class) public class RootEntity { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "root_entity_seq") @SequenceGenerator(name = "root_entity_seq", sequenceName = "ROOT_ENTITY_ID_SEQ", allocationSize = 1) private long id;
@OneToMany(mappedBy = "rootEntity", fetch = FetchType.LAZY, cascade = CascadeType.ALL) @Loader(namedQuery="loadChildEntities") private Set<ChildEntity> childEntities = new HashSet<ChildEntity>(0); ...
And the ChildEntity:
@Entity @Table(name = "CHILD_ENTITY") public class ChildEntity { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "child_entity_seq") @SequenceGenerator(name = "child_entity_seq", sequenceName = "CHILD_ENTITY_ID_SEQ", allocationSize = 1) private long id;
@ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "PARENT") private RootEntity rootEntity; ...
Example maven project attached to this issue.
|