-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: insert data into a column based on other column of the table
PostPosted: Tue Jan 18, 2011 1:48 pm 
Newbie

Joined: Thu Oct 29, 2009 8:38 pm
Posts: 2
Hi,

I would like to insert/update a column using a formula, which is similar to retrieving a column based on formula.

Below is the sample code,
---------------------------------
<property column="emp_id" generated="never" lazy="false"
name="emp_id" />
<property name="department" column="department_id" lazy="false"
formula="(select e.department_id from EMPLOYEE e where e.emp_id = emp_id)" />
--------------------------------------

The idea, is to track department_id of an employee which will/can change frequently


Top
 Profile  
 
 Post subject: Re: insert data into a column based on other column of the table
PostPosted: Tue Jan 18, 2011 5:47 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Check out if a "column transformer" is something that may work for you: http://docs.jboss.org/hibernate/core/3. ... -and-write

I discovered this just a few days ago so I think it is a fairly new feature (eg. Hibernate 3.6) and I haven't tried it myself.


Top
 Profile  
 
 Post subject: Re: insert data into a column based on other column of the table
PostPosted: Tue Jan 25, 2011 1:21 pm 
Newbie

Joined: Thu Oct 29, 2009 8:38 pm
Posts: 2
Hi,

Thanks a lot for the quick response.

Since I had restriction to upgrade to 3.5 in our project. I did a workaround.
I am resetting the fields in Java and saving it.

May be in future, I would like to sue the column transformer feature.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.