-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: object update problem
PostPosted: Fri Jan 07, 2005 3:07 am 
Newbie

Joined: Wed Oct 13, 2004 11:54 pm
Posts: 6
Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
can i update a transient object directly?
I instantiate a new object,its coresponding record exists in the database,i set all it's properties,can i direct update this object,like this(i skipp some code):
Person person=new Person();
person.setId("00001");
person.setAge(new Integer(12));
Session s=SessionFactory.openSession();
Transaction tx=s.beginTransaction();
session.update(person);
tx.commit();
thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 3:35 am 
Regular
Regular

Joined: Fri Nov 12, 2004 12:07 am
Posts: 57
Location: Beijing,China
Hi,

You should rewrite your code as below:

Person person=session.get("00001");
person.setAge(new Integer(12));
session.flush();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 3:43 am 
Newbie

Joined: Wed Oct 13, 2004 11:54 pm
Posts: 6
amjn wrote:
Hi,

You should rewrite your code as below:

Person person=session.get("00001");
person.setAge(new Integer(12));
session.flush();



thank u very much,I konw it can work well,i want to konw can i update a transient object directly


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 4:16 am 
Newbie

Joined: Wed Oct 13, 2004 11:54 pm
Posts: 6
I am so sorry, i read the api doc,I found update(Object obj) ,the parameter obj is a transient instance containing updated state.waste your time ,i really so sorry.the problem i have must be another problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.