-->
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.  [ 6 posts ] 
Author Message
 Post subject: "length" attribute for Date-typed properties (Midd
PostPosted: Fri Dec 02, 2005 5:46 pm 
Newbie

Joined: Thu Oct 27, 2005 6:01 pm
Posts: 15
I noticed that Middlegen puts the "length" attribute into the XDoclet mappings of properties of type Date (or its java.sql.* subclasses.) I have several questions related to that:

1. Is there any meaning to "length" attribute when used in Date-typed properties?

2. What exactly does Hibernate do with them?

3. If those length attributes are used to tell Hibernate whether this Date property should hold just the date vs. just the time vs. both, isn't it better to specify type="date"/type="time"/type="datetime" instead? Or is there any value in using both type and length attributes together in this context?

Thanks in advance.

Eugene

P.S. BTW, Middlegen Hibernate plugin generates type="java.sql.Timestamp", type="java.sql.Date", etc. in the .hbm.xml mappings, but hbm2java then ignores it and creates java.lang.Date typed properties. Which one is right, i.e. which one is preferable to use with Hibernate? (I guess it's Q#4. :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 6:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you should not have javax.sql types in your pojos since its an impl detail. java.util.Date is the proper representation for both timestamps and date in java (unfortunately)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 6:20 pm 
Newbie

Joined: Thu Oct 27, 2005 6:01 pm
Posts: 15
Thanks Max, that helps. Now, what about the mappings (specifically, the length and type attribute?)

Eugene


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 6:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
1/2 depends on the underlying dialect (but for timestamp i would guess everyone has a "pure" timestamp/date that does not need a length)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 11:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Ignore the length attribute as in the date context it has no meaning. The Meta data reports a length value so Middlegen generates it. I never bothered with checking the context as it does not matter. The type generated depends on which type mapper you have configured (hence you can also supply your own as an alternate to the existing ones) - remember Middlegen is generic at the core and that type is appropriate for other tools. In anycase, set it up the way you want it to work.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 03, 2005 12:57 am 
Newbie

Joined: Thu Oct 27, 2005 6:01 pm
Posts: 15
Thanks David. Very helpful, as usual.

Eugene


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.