-->
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: Same code base deployed to different databases
PostPosted: Mon Mar 07, 2011 9:55 am 
Newbie

Joined: Mon Mar 07, 2011 7:20 am
Posts: 1
All,

We wish to target two different deployment strategies. The first will be from a single webserver to a single oracle database server. For this we have used the following attributes in the common base class for our entities, which uses hibernate increment to generate the PKs

@Id
@GenericGenerator(name = "hibernate-increment", strategy = "increment")
@GeneratedValue(generator = "hibernate-increment")
@Column(name = "ID", insertable = false, updatable = false, nullable = false)
public Long getId() {
return id;
}

We also want to target SQL Azure and run our app on multiple webserver instances in the cloud. To do this we changed the attributes to use SQL Server's identity column to generate the PK

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID", insertable = false, updatable = false, nullable = false)
public Long getId() {
return id;
}

This is fine and works. However we have multiple projects and some will be on cloud and some will be off. Hence we would like to be able to make a runtime choice as to which "primary key generation strategy" to use. I am sure that this can be done - its just that I can't come up with the correct terms to search for in google/forum.

I thought that perhaps we could use a custom AnnotationSessionFactoryBean - presumably the postProcessAnnotationConfiguration method would allows us to search for and then tweak the strategy to use for our base class?

Any help/pointers greatly appreciated

Thanks

Chris


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.