the following code fragment when invoked in the application does not get
any JPA exceptions,
but always reports em.contains(item) as false;
when i use the same Entity classes in a standalone POJO app using JPA,
with RESOUCE LOCAL,
anytime an Item instance is persisted by em.persist(item)
i always get back from em.contains(item) the value true;
the item does get put into the derby database; but the PKey field stays null
in the local copy;
I am new to JPA -- so trying to understand what the problem is and where;
this code is from the Sun's Java Blueprints Petstore 2 EA5 Sample,
int CatalogFacade.java, method AddItem(Item item).
code fragment -----
utx.begin();
em.joinTransaction();
for (Tag tag : item.getTags()) {
tag.incrementRefCount();
tag.getItems().add(item);
em.merge(tag);
}
System.out.println("contains ni : " + em.contains(item));
--get false
System.out.println(item.getItemID()); --get null --
autogenerated PK
em.persist(item);
System.out.println("contains ni : " + em.contains(item));
-- get false
System.out.println(item.getItemID()); -- get null
em.flush();
System.out.println("contains ni : " + em.contains(item));
-- get false
System.out.println(item.getItemID()); -- get null
utx.commit();
System.out.println("contains ni : " + em.contains(item));
-- get false