collection « EntityManager « JPA Q&A





1. JPA/Hibernate entityManager.persist(..) makes the entity's collection to become null even though they are saved    stackoverflow.com

I have a PurchaseEntity that has a Set inside. After doing entityManager.persist(purchaseEntity), purchaseEntity itself and purchaseItemEntity's are all saved to DB correctly. But after that entityManager.persist(purchaseEntity) call, purchaseEntity.getItems() returns null. Is this a normal ...

2. Refreshing collection (getResultList) of entities bu entityManager.refresh    stackoverflow.com

How to refresh getResultList collection of entities when JPA cache is enabled. I mean: List customers = query.getResultList(); ????? > em.refresh ( customers ) ! // i need refresh because the cache is ...

3. Hibernate EntityManager working with Collections    coderanch.com

I have an entity (InvalidAddress) with a many to one relationship with another entity (ServiceRequest). I am trying to add an InvalidAddress entity to the InvalidAddressCollection owned by ServiceRequest InvalidAddress invalidAddress = new InvalidAddress(); //perform setters on invalidAddress invalidAddress.setServiceRequest(serviceRequest); serviceRequest.getInvalidAddressCollection().add(invalidAddress); entityManager.persist(invalidAddress); I am getting a NPE because serviceRequest.getInvalidAddressCollection() is returning null when there are no related InvalidAddress entities. I know this ...