Re: [Resin-interest] small question about entity ejb

2008-03-12 Thread Riccardo Cohen
I found what was wrong, the begin() was not at the right place : query = ... homeobj = (Home) query.getSingleResult(); _ut.begin(); homeobj.setTitle("new-title"); _ut.commit(); Sorry for the trouble. I'll write a little sample to clarify all that (for me at least) The @

Re: [Resin-interest] small question about entity ejb

2008-03-12 Thread Scott Ferguson
On Mar 11, 2008, at 6:28 AM, Riccardo Cohen wrote: > After some new tests, I found something that works : > > if I do : > > homeobj=m_manager.find(homeinfo.class,theid); > homeobj.setTitle(title); > > the object is saved > but if I use the homeobj that comes from > > Query hqr=m_m

Re: [Resin-interest] small question about entity ejb

2008-03-11 Thread Scott Ferguson
On Mar 11, 2008, at 6:28 AM, Riccardo Cohen wrote: > After some new tests, I found something that works : > > if I do : > > homeobj=m_manager.find(homeinfo.class,theid); > homeobj.setTitle(title); > > the object is saved > but if I use the homeobj that comes from > > Query hqr=m_m

Re: [Resin-interest] small question about entity ejb

2008-03-11 Thread Riccardo Cohen
After some new tests, I found something that works : if I do : homeobj=m_manager.find(homeinfo.class,theid); homeobj.setTitle(title); the object is saved but if I use the homeobj that comes from Query hqr=m_manager.createQuery("select h from homeinfo h where h.id_user="+id_us

Re: [Resin-interest] small question about entity ejb

2008-03-11 Thread Riccardo Cohen
Hi again, I tried @TransactionAnnotation but it generated frequent errors like this : [10:44:42.851] {http--8000-2} error: cannot read: mp/adminservlet.java [10:44:42.851] {http--8000-2} 1 error the select still work but no update I tried then with the UserTransaction method, but there was no

Re: [Resin-interest] small question about entity ejb

2008-03-10 Thread Scott Ferguson
On Mar 10, 2008, at 1:29 AM, Riccardo Cohen wrote: > Thanks a lot, I understand that I need a transaction now, while before > it could work without this... I have no idea of how to do that. > > I noticed that in the doc of amber > (http://caucho.com/resin/doc/amber.xtp) there was a > @Transaction

Re: [Resin-interest] small question about entity ejb

2008-03-10 Thread Riccardo Cohen
Thanks a lot, I understand that I need a transaction now, while before it could work without this... I have no idea of how to do that. I noticed that in the doc of amber (http://caucho.com/resin/doc/amber.xtp) there was a @TransactionAnnotation but this makes a syntax error ! Thanks to eclipse

Re: [Resin-interest] small question about entity ejb

2008-03-10 Thread Daniel López
Hi again, Some quick tests show that no persist() or merge() should be necessary to update an entity inside a persistent context. I tested with Hibernate and Amber as persistence providers and in both cases, nothing was necessary. That was using Resin 3.1.5 and RESOURCE_LOCAL as transaction ty

Re: [Resin-interest] small question about entity ejb

2008-03-10 Thread Daniel López
AFAIK, using merge should not be necessary unless the entity has been updated outside a "persistent context" and then needs to be synchronised back with the DB contents. persist() is just for new entities so reading the docs, updating an entity inside a persistent context should require no acti

Re: [Resin-interest] small question about entity ejb

2008-03-09 Thread Matt Johnston
I think you will need to use either the persist() or merge() methods of the EntityManager in order to save your data to the database. In your case since you are updating an existing record, you will need to use: m_manager.merge(homeobj) Matt Riccardo Cohen wrote: > Hi > I used to play with en

[Resin-interest] small question about entity ejb

2008-03-09 Thread Riccardo Cohen
Hi I used to play with entity ejb with resin 3.0 with no problem. Now in 3.1.5 I have this code : @PersistenceContext(name="public") private EntityManager m_manager; public boolean set_homeinfo(int id_user,String title) { boolean success=false; Query hqr=m_manager.createQuery(