遅延ロードされたコレクションを持つエンティティ(連絡先)があります。これを変更する必要はありませんが、em.find(Contact.class、myID)を実行するときにコレクションをロードする必要があります。これは、エンティティを変更せずに、フェッチでjpqlステートメントを使用せずに実行できます。?
public class Contact implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@Column(name="contactId", nullable=false)
public String contactId;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "contact", orphanRemoval = true, fetch=FetchType.LAZY)
private List<ContactTaskRelation> taskRelations = new ArrayList<ContactTaskRelation>();
}
私の統計のない豆から
@PersistenceContext(unitName="myContext")
private EntityManager em;
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private Contact getContact(ContactMapping mappedContact){
//force em to load the collection of taskRelations
return em.find(Contact .class, mappedContact.getContact());
}