Mitesh Meswani wrote:
>
> You have to set the relationship from both sides. That is add new
> attribute to the list of attributes from device.
>
but even if I try and get the Device again, the attribute will not show up.
So for instance:
Device device = new Device();
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
em.persist(device);
tx.commit();
em.close();
// ...
Attribute attribute = new Attribute();
attribute.setDevice(device);
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
em.persist(attribute);
tx.commit();
em.close();
Device device2;
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
device2 = (Device)em.find(Device.class, device.getPrimaryKey());
tx.commit();
em.close();
In this case device2.getAttributeCollection() returns a size of zero. I
don't understand how this is possible. If I look in the database, the
attribute exists there. For some reason TopLink never does a SELECT from
the attribute table.
--
View this message in context: http://www.nabble.com/JPA-issue---not-able-to-view-an-entity%27s-collection-tp18539580p18540285.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.