File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Hibernate: column function on insert/update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: column function on insert/update" Watch "Hibernate: column function on insert/update" New topic

Hibernate: column function on insert/update

Bob Runstein

Joined: May 21, 2002
Posts: 6
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;

Bob Runstein<br />Microsoft Certified Professional<br />Sun Certified Developer for the Java 2 Platform<br />Sun Certified Enterprise Architect for the Java 2 Platform<br /> <br />BR Solutions LLC<br />20797 E. Fair Ln<br />Centennial, CO 80016<br />720-870-7244 home<br />720-254-8966 cell<br />
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

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.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Hibernate: column function on insert/update
It's not a secret anymore!