You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Gurkan Erdogdu <gu...@yahoo.com> on 2007/09/14 00:44:20 UTC
EntityManager.find problem
Hi I am using 0.9.7 version. My problem is that;
I got managed object User. I want to update status of user. The below code does noting when commit transaction;
EntityManager manager = get entitymanager
EntityTransaction transaction = manager.getTransaction();
User user = manager.find(User.class,useroid);
user.setstatus('s');
transaction.commit;
manager.close;
But when I changes the code to get user object with query, then it works when commit transaction and update database
EntityManager manager = get entitymanager
EntityTransaction transaction = manager.getTransaction();
Query q = manager.createQuery('select c User c where c.oid=:oid');
User user = q.getResultList().get(0);
user.setstatus('s');
transaction.commit;
manager.close;
What is the problem with manager.find()?
Thanks;
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell.
http://searchmarketing.yahoo.com/
Re: EntityManager.find problem
Posted by Patrick Linskey <pl...@gmail.com>.
Hi,
Is there any way you could post a unit test that demonstrates the problem?
-Patrick
On 9/13/07, Gurkan Erdogdu <gu...@yahoo.com> wrote:
> Hi I am using 0.9.7 version. My problem is that;
>
> I got managed object User. I want to update status of user. The below code does noting when commit transaction;
>
> EntityManager manager = get entitymanager
> EntityTransaction transaction = manager.getTransaction();
>
> User user = manager.find(User.class,useroid);
> user.setstatus('s');
>
> transaction.commit;
>
> manager.close;
>
> But when I changes the code to get user object with query, then it works when commit transaction and update database
>
>
> EntityManager manager = get entitymanager
>
> EntityTransaction transaction = manager.getTransaction();
>
>
> Query q = manager.createQuery('select c User c where c.oid=:oid');
> User user = q.getResultList().get(0);
>
>
> user.setstatus('s');
>
> transaction.commit;
>
>
>
> manager.close;
>
> What is the problem with manager.find()?
>
> Thanks;
>
>
>
>
>
>
>
>
> ____________________________________________________________________________________
> Pinpoint customers who are looking for what you sell.
> http://searchmarketing.yahoo.com/
>
--
Patrick Linskey
202 669 5907