-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate config for trigger provided data?
PostPosted: Fri Jun 25, 2010 2:06 pm 
Newbie

Joined: Fri Jun 25, 2010 1:53 pm
Posts: 2
I am evaluating whether or not to use Hibernate for a new app that will re-use an existing Oracle DB schema that is used by many other applications. In this schema, nearly all of the tables have more than one column where default values are provided by triggers in situations where no value has been provided for that column (e.g. a logical deleted column (flag)). The symptom I am seeing in using Hibernate is that it will not allow the persistence of an object where a value has not been provided for one of these prior mentioned fields (columns they are not-null and a trigger provides a default value). So far I am not seeing an elegant solution to this. Below are things I have considered but ruled out
1) Having the hibernate data object provided a default value for the field
---- This is bad solution because you are duplicating what you think the trigger is going to do
2) Having the hibernate .hbm file define a default value for that object it supports (defines).
---- This is bad solution for same reason as 1
3) Change the table to allow nulls
---- This is a bad solution because other existing applications are relying on the functionality that have been getting out of the trigger. And secondly, because a middle tier layer should not be DB invasive.

What is the hibernate solution to this case?
The solution cannot be DB schema invasive in any way because of existing apps, and the solution cannot be a 're implementation' of what the triggers provide.
Thoughts?
Thanks!
Cheers,
Will-


Top
 Profile  
 
 Post subject: Re: Hibernate config for trigger provided data?
PostPosted: Fri Jun 25, 2010 5:37 pm 
Newbie

Joined: Fri Jun 25, 2010 1:53 pm
Posts: 2
I believe I have found an answer, and it involves using the attribute 'generated' with a value of 'insert'.
The entry looks like:
.........
<property name="lastModifiedDate" type="date" generated="insert">
<column name="LAST_MODIFIED_DATE" length="7" not-null="true">
<comment>Date the record was last modified.</comment>
</column>
</property>
.........


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.