Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to map Date

 
satyamreddy reddybrother
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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>
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic