-->
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.  [ 2 posts ] 
Author Message
 Post subject: Retrieve a primary key value which is set by hibernate
PostPosted: Mon Jul 13, 2009 7:59 am 
Newbie

Joined: Mon Jul 13, 2009 7:47 am
Posts: 4
I have a Trade object in Java which has methods setTradeId() and getTradeId().

Hibernate automatically sets a value for the tradeid which is the primary key of this table.

Java Code:
-----------
Trade trade = new Trade();
//trade.setId(189); // Automatic generation.I dont need to invoke this method.
trade.setTradeDate(new Date());
trade.setName("Testing");

<class name="com.aurica.fx.options.trade.Trade" table="TRADE">

<id name="TradeId"
type="int"
column="TRADEID" >
<generator class="assigned"/>
</id>


Now,how do I retrieve this e primary key value?


Top
 Profile  
 
 Post subject: Re: Retrieve a primary key value which is set by hibernate
PostPosted: Wed Jul 15, 2009 1:17 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
After you save and commit the primary key will be in your field. Hibernate should automatically fill the field for you. You might want to just try to see if it's there after a save, because I could be wrong about the commit.

_________________
Please rate my replies as I need points for all of my questions also.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.