Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Override id generation strategy [Spring] [Hibernate]  RSS feed

Eric Cornely
Posts: 9
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 : but how could I configure spring to configure hibernate so that it reads those files ?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!