You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Suneet Shah <su...@gmail.com> on 2008/05/19 23:16:46 UTC

Converting Spring POJOs to WebServices with CXF

Hello:

I have a set of POJOs that are built using Spring and Hibernate. Some
of these have pojos have many to many relationship as shown in the
hibernate maps below.

When I try to generate a WSDL, I run into a problem due to the
circular reference.
How are other people working around this without loosing the
functionality that they need on the hibernate side.

thanks.

--- Hibernate maps ---
In the tables below I have a Many to Many relationship between Group
and Role. GroupRole does the linking between these tables.

Group

[code]   <class name="Group" table="GRP" >

        <comment></comment>
        <id name="grpId" type="string">
            <column name="GRP_ID" length="20" />
            <generator class="assigned" />
        </id>
        <property name="grpName" type="string">
            <column name="GRP_NAME" length="40">
                <comment></comment>
            </column>
        </property>

        <property name="companyId" type="string">
            <column name="COMPANY_ID" length="20">
                <comment></comment>
            </column>
        </property>
        <property name="parentGrpId" type="string">
            <column name="PARENT_GRP_ID" length="20">
                <comment></comment>
            </column>
        </property>

        <property name="groupClass" type="string">
            <column name="GROUP_CLASS" length="40">
                <comment></comment>
            </column>

        <set name="groupRoles" cascade="all-delete-orphan" lazy="true"
inverse="true">
            <key>
                <column name="GRP_ID" length="20" not-null="true">
                    <comment></comment>
                </column>
            </key>
            <one-to-many class="GroupRole" />
        </set>

    </class>[/code]



[b]Role[/b]

[code]<hibernate-mapping>
    <class name="Role" table="ROLE" >
        <comment></comment>
        <id name="roleId" type="string">
            <column name="ROLE_ID" length="20" />
            <generator class="assigned" />
        </id>
        <property name="serviceId" type="string">
            <column name="SERVICE_ID" length="20">
                <comment></comment>
            </column>
        </property>
        <property name="roleName" type="string">
            <column name="ROLE_NAME" length="40">
                <comment></comment>
            </column>
        </property>

        <set name="grpRoles" fetch="select" cascade="all-delete-orphan">
            <key>
                <column name="ROLE_ID" length="20" not-null="true">
                    <comment></comment>
                </column>
            </key>
            <one-to-many class="GroupRole" />
        </set>

    </class>
</hibernate-mapping>[/code]

[b]GroupRole[/b]


[code]<hibernate-mapping>
    <class name="GroupRole" table="GRP_ROLE" >
        <comment></comment>
        <id name="grpRoleId" type="string">
            <column name="GRP_ROLE_ID" length="20" />
              <generator class="SequenceGenerator">
                 <param name="table">sequence_gen</param>
                 <param name="column">next_id</param>
                 <param name="attribute">GRP_ROLE_ID</param>
       		  </generator>
        </id>

        <many-to-one name="role" class="Role" fetch="select">
            <column name="ROLE_ID" length="20" not-null="true">
                <comment></comment>
            </column>
        </many-to-one>
        <many-to-one name="group" class="Group" fetch="select">
            <column name="GRP_ID" length="20" not-null="true">
                <comment></comment>
            </column>
        </many-to-one>


        <property name="serviceId" type="string">
            <column name="SERVICE_ID" length="20" not-null="true">
                <comment></comment>
            </column>
        </property>

    </class>
</hibernate-mapping>
[/code]