We have got a requirement for multiple schemas in Hibernate.
In our project, we need to connect to multiple schemas based on the username and password. But how to configure multiple schemas in Hibernate?
Please let me know if there's a way.
hibernatehibernate-criteriahibernate-mappingormspring
We have got a requirement for multiple schemas in Hibernate.
In our project, we need to connect to multiple schemas based on the username and password. But how to configure multiple schemas in Hibernate?
Please let me know if there's a way.
Best Answer
You can specify it by
schema
element while defining table for your entity.Else, you can use separate
EntityManager
pointing to respective schema & then use the same entity, as their structure is similar.Edit : You can have separate configuration files for each schema & then build
SessionFactory
from it, below is some pseudo-code for it.You can refer this link for further details to map multiple schema, but it isn't hibernate specific.