schema names in hibernate can be painful but not with the latest releases
Refer to the following URL and you will get useful information of setting the schema names for the application at different levels
- Global Level
- Entity Level
- Property Level and
- Association Level
For JPA rather than doing it in every ENTITY class
just create the orm.xml with the following contents
<?xml version="1.0" encoding="UTF-8" ?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
version="1.0">
<persistence-unit-metadata>
<persistence-unit-defaults>
<schema>mySchema</schema>
</persistence-unit-defaults>
</persistence-unit-metadata>
</entity-mappings>
Make sure that you refer this from the persistence.xml as follows
<persistence-unit>
<mapping-file>META-INF/orm.xml</mapping-file>
</persistence-unit>
No comments :