aspose file tools*
The moose likes Object Relational Mapping and the fly likes Override id generation strategy [Spring] [Hibernate] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Override id generation strategy [Spring] [Hibernate]" Watch "Override id generation strategy [Spring] [Hibernate]" New topic
Author

Override id generation strategy [Spring] [Hibernate]

Eric Cornely
Greenhorn

Joined: Aug 03, 2011
Posts: 5

Hello,

I'm working on a project with Spring 2.5.6 and Hibernate 3.6.3. In every environment we're using sequences to generate Integer id for all our entities so :



But in my unit tests I'd like to use an in memory database like HSQL-DB and use an auto_increment so I would need to replace it by @GeneratedValue(strategy=GenerationType.IDENTITY).

How can I override that annotation only for unit tests ?

I'm already having a different spring configuration so I probably should be able to initialize a session factory that read XML definitions instead of annotations but how ?

Here is the spring configuration for my sessionFactory :


It's seems that I can easily override it according to that : http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/xml-overriding.html but how could I configure spring to configure hibernate so that it reads those files ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Override id generation strategy [Spring] [Hibernate]