-->
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.  [ 1 post ] 
Author Message
 Post subject: Auto increment column in composite key
PostPosted: Fri Apr 10, 2009 2:36 pm 
Newbie

Joined: Tue Oct 02, 2007 10:54 pm
Posts: 4
I am using mysql 5.1 and hibernate 3.1

I have a class called Transaction with a composite key(plan, member, transactionId) where transactionId is an auto increment column.

This is how my mapping looks like



Code:
<composite-id>
              <key-property name="planId" column="Plan_ID"/>
              <key-property name="memberId" column="Member_Id"/>
              <key-property name="tranSeqNum" column="Tran_SeqNum"/>
</composite-id>


When i want to insert a transaction Object i do this

Code:
Transaction transaction = new Transaction("22222","33333",null);
session.save(transaction);
transaction.getTranSeqNum().intValue()  // Throws null pointer


How do i access the value of auto generated number by the database?
In the database it saves it fine if i remove the third line tho


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

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.