I use Spring 4, Hibernate 4 and WebSphere 8.5.7. Having such a class:
@Entity
@Table(name = "APPLICATION", schema = "NEW_SCHEMA")
public class Application {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_NEW")
@SequenceGenerator(name = "SEQUENCE_NEW", schema = "NEW_SCHEMA", sequenceName = "SEQUENCE_NEW", allocationSize = 1, initialValue = 1)
@Column(name = "ID")
@Getter @Setter private Long id;
I want to have an ability to change a schema in the @Table signature via JNDI name. I expect to get something like this:
@Table(name = "APPLICATION", schema = "${schema.jndi}")
Assuming that ${schema.jndi}
will be provided by Websphere.
Another words, in business context, the task looks as follows. I need to exclude any mention of the schema in a whole project code (Java, xml, props). And make it possible changing a schema directly from WebShpere.
What is the simplest way to implement a solution?
Any suggestion will be greatly appreciated.
If you want to configure a schema for the entire application (for every entity) , you can do that in your Hibernate configuraton file (typically WAS will have a reference to this config file)
<property name="hibernate.default_schema">myschema</property>