Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: column function on insert/update

 
Bob Runstein
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Hibernate support processing values with database functions for insert and update? My classes contain character representations of Oracle OLS labels which need to be converted to numbers using Oracle's to_data_label function. This function cannot be reproduced in java since the mapping is done via Oracle's OLS policy tables and I do not want to make a separate query to get the values from Oracle.

The sql I want would look something like this:
update myClass set myColumn = to_data_label(myClassAttribute)
where id = 100;
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate does not support the various DB extentions to SQL you see accross all the various flavours of Database. But it does provide createSQLQuery methods (see net.sf.hibernate.Session) which let you call native SQL for those special cases. I'd always re-examine the need for platform specific SQL though. It might be unavoidable, but if not approached carefully you end up negating one of the main benefits of using an ORM technology: it's usefullness cross platform.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic