Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Date Mapping

 
Yoo-Jin Lee
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In hibernate 3.0 is there a way to map a varchar (in database) to a java.util.Date for your DTO?

The simplest solution I know is to add the following to your hbm.xml class and DTO:

(1) private field with private getter/setter that hibernate will populate
- the setter will convert the format for (2)
(2) public field with public getter/setter that users will use

Any other ideas?

Thanks in advance.

Yoo-Jin
[ May 04, 2005: Message edited by: Yoo-Jin Lee ]
 
Yoo-Jin Lee
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah just found UserType.... Excellent.
 
Neerajplus Kumarplus
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what's your requirement but I find UserType a heavy weight solution which should be used when hibernate doesn't support the data type natively.

In your case, with my limited understanding of the problem, I would set the field as varchar and would define as "access" = "field". In this way you can have yout getValue() method that would return date field.
 
Neerajplus Kumarplus
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what's your requirement but I find UserType a heavy weight solution which should be used when hibernate doesn't support the data type natively.

In your case, with my limited understanding of the problem, I would set the field as varchar and would define as "access" = "field". In this way you can have yout getValue() method that would return date field.
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!