These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: entity mapping: convert from hbm.xml to orm.xml
PostPosted: Thu Dec 22, 2011 6:31 am 
Newbie

Joined: Wed Nov 30, 2011 5:13 am
Posts: 2
Hi all,

I´m new to hibernate and I must convert the Entity Mapping in an application from hbm.xml to orm.xml. My Problem is that I am missing some fields and attributes to convert correctly.

this is the hbm.xml which I´m trying to convert:
Code:
<hibernate-mapping package="server.model.history">

    <typedef name="outputType" class="org.hibernate.type.EnumType">
        <param name="enumClass">server.model.history.OutputType</param>
        <!-- Hibernate type '4' means Integer -->
        <param name="type">4</param>
    </typedef>

    <class name="ProcessOutput" table="PROCESS_OUTPUT" mutable="false">

        <id name="id" column="ID" type="server.model.id.hibernate.ProcessOutputIdUserType" access="field">
            <generator class="info.novatec.np.server.model.id.hibernate.CustomGenerator" />
        </id>

        <discriminator column="HOST_KIND" type="string"/>
       
        <version name="version"
                 access="field"
                 column="VERSION"
                 type="integer"/>

        <property name="sequence" column="SEQUENCE" type="integer" not-null="true" unique-key="UNIQUE_SEQUENCE_CREATED_PROCESSID" access="field"/>
       
        <list name="variables" table="HOST_VARIABLE" cascade="all">
            <key column="FK_HOST_ID"/>
            <list-index column="INDEX" />
            <composite-element class="server.model.SimpleKeyValuePair">
                <property name="key" access="field" column="KEY" type="string" not-null="true" />
                <property name="value" access="field" column="VALUE" type="string"/>
            </composite-element>
        </list>
       
        <many-to-one name="process" class="ProcessStep" column="FK_PROCESS_ID" not-null="true" unique-key="UNIQUE_SEQUENCE_CREATED_PROCESSID" access="field" index="OUTPUT_FOREIGNKEY_INDEX" />
       
    </class>
</hibernate-mapping>


and here is how I convert it to orm.xml so far:

Code:
<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">

    <package>info.novatec.np.server.model.history</package>

    <entity class="ProcessOutput">
        <table name="PROCESS_OUTPUT" />

        <attributes>
            <id name="id">
                <column name="ID" />
            </id>
           
       <version name="version" ><column name="VERSION"/></version>

            <basic name="sequence">
                <column name="SEQUENCE" nullable="false"/>
            </basic>

            <many-to-one name="process" ></many-to-one>

        </attributes>
    </entity>
</entity-mappings>


as you can see it is incomplete, scrappy and partly incorrect.
How can I write the id_type id_access and generator class in the orm.xml??
I also didn´t find nothing equivalent to <property unique-key and type/> and many-to-one index
what about the discriminator and <typedef name="..." class="..." <param.../> .../>??

I would be thankful and It would be great for any help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.