-->
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: Problem with date type in composite key
PostPosted: Mon Dec 04, 2006 1:34 am 
Newbie

Joined: Fri Sep 09, 2005 11:40 am
Posts: 12
Hibernate version:3.0

Mapping documents:


<hibernate-mapping>
<class name="Request" table="request">
<composite-id name="id" class="RequestId">
<key-property name="personId" type="long">
<column name="id"/>
</key-property>
<key-property name="courseId" type="long">
<column name="course_id"/>
</key-property>
<key-property name="startDate" type="date">
<column name="start_date"/>
</key-property>
</composite-id>
</class>
</hibernate-mapping>



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

Full stack trace of any exception that occurs:
...
Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Attempt to insert duplicate key row in object 'request' with unique index 'pk_request'

at com.sybase.jdbc3.tds.Tds.processEed(Tds.java:2942)
at com.sybase.jdbc3.tds.Tds.nextResult(Tds.java:2246)
at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:220)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:203)
at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(SybStatement.java:1804)

....



Name and version of the database you are using:Sybase 12.5.0



I have a composite key which includes a Sybase datetime column type. I am using a java.util.Date object for this field and I am able to insert a record depending on the data and the existing data but I am having problems with updates. Although the columns which make up the composite key are different I get a unique key identifier violation.

I will also get this during an update occasionally.

I am using composite keys elsewhere without problems but those keys do not contain a date. I am suspecting that the problem is the date field but not sure what the fix is. Anyone have any ideas?


Thanks in advance.


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.