Can I Override Metadata using ORM.xml for JPA 2 in JBoss EAP?

Solution Verified - Updated -

Issue

I am trying to override entity metadata as follows:

1) I need to override basic field
2) The basic filed has the following annotation

@Column(name = "OCCUPIED")
@org.hibernate.annotations.Type(type="yes_no")       
private boolean occupied;

3)My goal is to remove @org.hibernate.annotations.Type(type="yes_no") from entity and define it in ORM.xml using XML configuration. I do not know how to correctly define org.hibernate.annotations.Type or org.hibernate.type.YesNoType in ORM.xml so the ORM.xml will be compliant
4) My ORM.xml has the following

<entity-mappings version="2.0" 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_2_0.xsd">
    <persistence-unit-metadata>
        <persistence-unit-defaults>
            <access>FIELD</access>
        </persistence-unit-defaults>
    </persistence-unit-metadata>
    <package>some.package</package>

    <entity class="someEntity"  >

       <table name="SOME_TABLE"/>
       <attributes>
         <id name="id">
           <column name="ID" />
           <generated-value strategy="SEQUENCE" generator="SomeTypeGenerator"/>
           <sequence-generator name="RoomTypeGenerator" sequence-name="seq_room_id" allocation-size="1" />
         </id>

         <basic name="name">
           <column name="NAME" />
         </basic>

         <basic name="occupied">
           <column name="OCCUPIED"/>
           <!-- 
           <org.hibernate.type.YesNoType>yes_no</org.hibernate.type.YesNoType>
           -->
           <org.hibernate.annotations.Type value="yes_no"/>        
         </basic>        
       </attributes>
    </entity>
</entity-mappings>

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content