-->
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: saveorupdate with assigned generator!!
PostPosted: Fri Oct 31, 2008 1:20 pm 
Newbie

Joined: Fri Oct 31, 2008 11:35 am
Posts: 12
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.3


how can i implement a save-update property but assigned a calculate id by my program??


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2008 1:35 pm 
Newbie

Joined: Fri Oct 31, 2008 1:19 pm
Posts: 5
You can try this way

Session s = null;

try{
s= getSession();
Transaction trans = s.beginTransaction();
ClassName instance= (ClassName ) s.get(ClassName .class, xxx);

//set the values

s.update(xxx);
trans.commit();



xxx: instance from POJO class whcih acts as the primary key.


Last edited by Shilpa Chalasani on Fri Oct 31, 2008 2:19 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2008 1:36 pm 
Newbie

Joined: Fri Oct 31, 2008 1:19 pm
Posts: 5
You can try this way

Session s = null;

try{
s= getSession();
Transaction trans = s.beginTransaction();
ClassName instance= (ClassName ) s.get(ClassName .class, xxx);

//set the values

s.update(xxx);
trans.commit();



xxx: instance from POJO class whcih acts as the primary key.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2008 3:29 pm 
Newbie

Joined: Fri Oct 31, 2008 11:35 am
Posts: 12
great!!!

i´ll try and tell you results more later


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.