-->
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: How to use database default in key-property in Composite key
PostPosted: Tue Jul 26, 2011 2:02 pm 
Newbie

Joined: Tue Oct 09, 2007 1:02 am
Posts: 5
We have a table with following columns in composite key:

1. AddDate
2. UserId
3. Password

Below is our mapping file:

Code:
<hibernate-mapping package="com.test.model">

    <class name="UsedUserPassword" table="UsedUserPassword" >
   
       <composite-id>
       
           <key-property name="addDate" type="timestamp" >
               <column name="AddDate" length="23" />
          </key-property>
          
          <key-property name="userId" type="int">
               <column name="UserID" />
          </key-property>
          
          <key-property name="password" type="string">
               <column name="Password" length="50" />
          </key-property>
          
       </composite-id>
       
    </class>
   
</hibernate-mapping>


Thus, all three columns are composite key. We are using MS-SQL DB, Hibernate 3 and want to use database default value of getdate() for AddDate column. However, there is no way to say insert="false" on AddDate column in mapping file. Please help!


Top
 Profile  
 
 Post subject: Re: How to use database default in key-property in Composite key
PostPosted: Tue Jul 26, 2011 4:09 pm 
Newbie

Joined: Tue Oct 09, 2007 1:02 am
Posts: 5
As a workaround to the above issue, I tried to initialize the AddDate column with new java.util.Date(). This threw an error: cannot perform lookups on timestamps

Searching further I found that we can't use timestamp in composite key.

Ref:

https://forum.hibernate.org/viewtopic.php?p=2239206
https://forum.hibernate.org/viewtopic.php?t=940213


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.