2

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:

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

<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, type and many-to-one index and what about the discriminator and typedef name="..." class="..." param.../> .../>??

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

ecutioner
  • 61
  • 2
  • 6

0 Answers0