• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

how to map Date

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello any body can help me

iam new hibernate iam mapping date field. when iam getting the date
filed from database(i want userdefined format like dd-mm-yyyy iam using oracle databse). for this how can i map. i tried using formula="some sql"
its working fine but when insertion time the data will not inseterted to databse bcz iam using formula.

<property name="lastUpdatedDate" type ="date" >
<column name= "LAST_UPDATED_DATE" sql-type ="date" formula ="to_char(LAST_UPDATED_DATE,'dd-mm-yyyy')" not-null = "true"/>
</property>
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remove the formula and is will work 'as is'. You shouldn't really use formula like that anyway since it breaks Hibernate's portability (the mapping you have supplied will only work with Oracle). Hibernate provide the formula element/attribute only for the exotic, one in a thousand situation you might need it.

How you handle the format of the date is the preserve of your application code, not Hibernate or Oracle.
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic