• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Date Mapping

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah just found UserType.... Excellent.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic