Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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

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.
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic