-->
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.  [ 1 post ] 
Author Message
 Post subject: How to create trigger programatically?
PostPosted: Sat Apr 10, 2010 12:14 am 
Newbie

Joined: Sat Apr 10, 2010 12:05 am
Posts: 1
I am facing a problem while writing a unit test case for a module. The mapping config of one of the object has a Version Property. In production we use Oracle database and the version number is created by a trigger in the database so i have to give generate = always and insert = false for this property as follows.
<version name="recordVersionNumber" column="RECORD_VERSION_NUMBER" generated="always" insert = "false" />
The problem I have is that now I can not write test cases for this object. When I try to save an object in my unit test case which is using the hsqldb hibernate fails to insert because record version number is empty. It is happening because there is no trigger in the hsql db that will generate the version number for us.
Now there are a few solutions that I can think of but I cant figure out how to implement them.
1. In the unit test cases we could set generate = never and insert = true programatically for this mapping. In that case hibernate will generate version number for us and our test cases will pass.
2. Add a trigger to the DB programatically.
3. make recordVersionNumber nullable. This will allow us to insert rows and we can then update the RVN and save the object.

I cant figure out any of the above solution. Any help will be highly appreciated


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

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.