You have to call em.merge(b) after you made a modification.
BeanType b = new BeanType(); b.setX(1); em.persist(b); b.setX(2); em.merge(b);
Thanks, I've seen that but based on my experience with other Persistence frameworks I expected the bean to be kept in sync with the database once it was persisted.
It seems that in EJB3.0 obtaining a bean from the database (via find) is not the same as introducing a bean to the database (via merge or persist) whereas in JDO and Hib3 I believe that the two were equivalent in this manner.
I have an entity bean that I am deploying in CR2, I am finding that the beans I instantiate via the EntityManager (ie a query returns them) are kept in sync with the database but when I create new instances outside of the persistence context and then use the Entity Manager persist (or merge) methods, they are added to the database but later changes to these beans' properties are not persisted.
BeanType b = new BeanType();
After this the database contains 1 in the column mapped to by properrty X, whereas I expected it to contain 2
It should work. Remember that you must have a running db transaction though.
Remember that you must have a running db transaction though.
Is this typically done through a wrapper method with the appropirate transaction attributes in such a case? I tried accessing the EntityManager's getTransaction() in my code and it [the call to getTransaction()] threw an EJBException.
yes this is done declaratively through @TransactionAttribute