-->
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: Hibernate 3 and date fields
PostPosted: Mon Apr 25, 2005 3:50 pm 
Newbie

Joined: Fri Jul 23, 2004 11:14 am
Posts: 9
I have a program which runs fine under Hibernate 2 with a table which uses a date as the primary key. The mapping looks like this:
Code:
    <class name="OutSum" table="out_sum">
        <cache usage="nonstrict-read-write"/>
        <id name="runDate" column="RUN_DATE" type="java.util.Date">
            <generator class="assigned"/>
        </id> ...


Hibernate will now complain when inserting new records that it "cannot perform lookups on timestamps". In this instance we are using MySQL 4.1.7-nt. Is this changed behavior? Should we be doing this another way?

Thank you

Tom


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 25, 2005 3:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It is very dangerous to use a timestamp as a primary key. Why would you do this?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 25, 2005 4:24 pm 
Newbie

Joined: Fri Jul 23, 2004 11:14 am
Posts: 9
I changed it to a java.util.Calendar field actually and it works fine.

In this particular application we recieve a data feed once per day. We didn't need a time stamp per say but we definately wanted to associate a batch of data with a particular time / date which it was generated. Having two files with an identical date / time would not be possible.

Thanks

Tom


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 26, 2005 8:34 am 
Newbie

Joined: Fri Jul 23, 2004 11:14 am
Posts: 9
If something is a time indexed sequence come to think of it, why would having a date / time object be a bad idea as an index?


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.