My Quotes


When U were born , you cried and the world rejoiced
Live U'r life in such a way that when you go
THE WORLD SHOULD CRY






Thursday, April 18, 2013

setting schema information


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


  1. Global Level
  2. Entity Level
  3. Property Level and
  4. 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 :