-->
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: type = "java.sql.timestamp" VS type = "java.
PostPosted: Thu Jan 12, 2006 12:02 am 
Beginner
Beginner

Joined: Fri Jun 17, 2005 7:24 am
Posts: 23
1)In hbm i code the type "type = "java.sql.timestamp"" but in java pojo it is java.util.Date. Is it correct?

/**
* @hibernate.property
* column = "created_date"
* type = "java.sql.timestamp"
* not-null = "false"
*
*/
public Date getCreatedDate() {
return this.createdDate;
}

2)In the hbm the type is java.util.Date but how about in DB. Is it sure all the database also is timestamp.

3) type = "java.sql.timestamp" VS type = "java.util.Date". How it will affect the DB.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 12:12 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You're mixing up class and type: it's very common. I see many mapping files containing type="java.lang.String", which I find quite amusing.

Hibernate types are defined in org.hibernate.type; you can add to them using your own user types. Those types are named using the class type of the user type; that's usually a long and cumbersome string, so use the <typedef> tag to create an alias for it.

Anyway, to answer your question: you want type="date". Have a look in org.hibernate.type.DateType: you'll see that it converts between java.sql.Date and java.util.Date for you.


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.