Composite id with a complex type as one of its members

Hello all, I’m new here and need to perform an operation but i don’t know if it is possible.

Right now I have a composite Id as such:

<composite-id name="a" class="com.b.c.d.e.s">
            <key-property name="a" access="field" column="A" type="int"/>
            <key-property name="b" access="field" column="B" type="int"/>
            <key-property name="c" access="field" column="C" type="java.lang.Long"/>

            <key-property name="d" access="field" column="D" type="int"/>
            <key-property name="e" access="field" column="E" type="int"/>
            <key-property name="f" access="field" column="F" type="java.lang.Long"/>

            <key-property name="g" column="G" type="com.h.y.g.x"/>
        </composite-id>

I need to create a new composite-id that contains the old composite id and a new primitive integer.
I tried something like this but it is not supported. Can anyone help me?


        <composite-id name="newID" class="com.a.b.c.d.e.f.newId">
            <key-property name="formerID" type="formerID"/>
            <key-property name="num" access="field" column="NUM" type="int"/>
        </composite-id>

<composite-id name="formerID" class="com.b.c.d.e.s">
            <key-property name="a" access="field" column="A" type="int"/>
            <key-property name="b" access="field" column="B" type="int"/>
            <key-property name="c" access="field" column="C" type="java.lang.Long"/>

            <key-property name="d" access="field" column="D" type="int"/>
            <key-property name="e" access="field" column="E" type="int"/>
            <key-property name="f" access="field" column="F" type="java.lang.Long"/>

            <key-property name="g" column="G" type="com.h.y.g.x"/>
        </composite-id>

Thanks in advance and best regards,
Rui

I don’t think that composite identifiers can be composed like that. However, you can just do that by copying the properties to the new identifier:

 <composite-id name="newID" class="com.a.b.c.d.e.f.newId">
        <key-property name="num" access="field" column="NUM" type="int"/>

        <key-property name="a" access="field" column="A" type="int"/>
        <key-property name="b" access="field" column="B" type="int"/>
        <key-property name="c" access="field" column="C" type="java.lang.Long"/>

        <key-property name="d" access="field" column="D" type="int"/>
        <key-property name="e" access="field" column="E" type="int"/>
        <key-property name="f" access="field" column="F" type="java.lang.Long"/>

        <key-property name="g" column="G" type="com.h.y.g.x"/>
    </composite-id>

It worked!

Thank you so much :slight_smile: