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
|