« - »

The Approval Service: DB to POJOs (Phase II)

15 February 2008

Completing the remainder of the RequestForApproval mapping involved generating two additional Hibernate mapping files, and then updating the original RFA mapping file to reference the two one-to-many relationships. The two new Hibernate mapping files are RequestForApprovalApprover.hbm.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

    <class name="org.restafarian.approval.beans.RequestForApprovalApprover"
          table="RequestForApprovalApprover">
        <id name="id">
            <generator class="native"/>
        </id>
        <property name="rfaId"/>
        <component name="approver">
	        <property name="id" column="approverId"/>
        	<property name="uri" column="approverURI"/>
        	<property name="name" column="approverName"/>
        </component>
        <property name="actionList"/>
    </class>

</hibernate-mapping>

… and RequestForApprovalAction.hbm.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

    <class name="org.restafarian.approval.beans.RequestForApprovalAction"
          table="RequestForApprovalAction">
        <id name="id">
            <generator class="native"/>
        </id>
        <property name="rfaId"/>
        <property name="dateTime" type="timestamp"/>
        <property name="activity"/>
        <component name="user">
	        <property name="id" column="userId"/>
        	<property name="uri" column="userURI"/>
        	<property name="name" column="userName"/>
        </component>
        <property name="comments"/>
    </class>

</hibernate-mapping>

The updated RequestForApproval.hbm.xml file now looks like this:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

    <class name="org.restafarian.approval.beans.RequestForApproval"
          table="RequestForApproval">
        <id name="id">
            <generator class="native"/>
        </id>
        <property name="type"/>
        <property name="state"/>
        <property name="payloadId"/>
        <property name="payloadURI"/>
        <component name="author">
	        <property name="id" column="authorId"/>
        	<property name="uri" column="authorURI"/>
        	<property name="name" column="authorName"/>
        </component>
        <property name="description"/>
        <property name="dateTime" type="timestamp"/>
        <set name="approvers" cascade="all-delete-orphan"
                 lazy="false" order-by="approverId">
            <key column="rfaId"/>
            <one-to-many
class="org.restafarian.approval.beans.RequestForApprovalApprover"/> 
        </set>
        <set name="actions" cascade="all-delete-orphan"
                 lazy="false" order-by="dateTime desc">
            <key column="rfaId"/>
            <one-to-many
class="org.restafarian.approval.beans.RequestForApprovalAction"/> 
        </set>
    </class>

</hibernate-mapping>

I also updated the dependent libraries in the Example.ear file to include all of the .jars needed to support both Betwixt and Hibernate. Including our own .jar files, the full list now looks like this:

I uploaded the entire completed package, which you can now get to here: Example3.ear.


http://blog.restafarian.org/2008/02/the-approval-service-db-to-pojos-phase-ii/

Comments are closed.

Sorry, the comment form is closed at this time.