-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to spring:bind a join table with composite-keys
PostPosted: Thu Mar 29, 2007 4:48 am 
Newbie

Joined: Thu Mar 29, 2007 4:17 am
Posts: 2
I think this is something common and I am hoping someone could give me some insights on my problems as follow:

I have got 3 tables:
Table A:
Fields: af1 = pk, af2, af3

Table B:
Fields: bf1 = pk, bf2, bf3

Table C [join table]:
Fields: cf1 + cf2 = composite keys, cf3, cf4

May i know how can i correctly register a custom editor within my spring controller as well as the spring:bind code segments in my jsp pages?

Below are some codes for reference:

Code:
*** Below shows the mapping of the join table with composite keys -> Table C
<hibernate-mapping>
    <class name="gis.gtb.cts2.data.ProcessSequencingMethod" table="CTS2_PROCESS_SEQUENCINGMETHOD" mutable="true" batch-size="20">
        <composite-id name="id" class="gis.gtb.cts2.data.ProcessSequencingMethod$Id">
            <key-property name="processId" access="field" column="PROCESS_ID"/>
            <key-property name="sequencingMethodId" access="field" column="SEQUENCINGMETHOD_ID"/>
        </composite-id>
        <property name="sequence" column="SEQUENCE" type="integer" not-null="true"/>
        <many-to-one name="process" column="PROCESS_ID" not-null="true" insert="false" update="false" fetch="join"/>
        <many-to-one name="sequencingMethod" column="SEQUENCINGMETHOD_ID" not-null="true" insert="false" update="false" fetch="join"/>
    </class>
</hibernate-mapping>


Code:
*** Below is the inner class for the composite keys
public static class Id implements Serializable {
        private Integer processId;
        private Integer sequencingMethodId;
        public Id() {}
        public Id(Integer processId, Integer sequencingMethodId) {
            this.processId = processId;
            this.sequencingMethodId = sequencingMethodId;
        }
        public boolean equals(Object o) {
            if (o != null && o instanceof Id) {
                Id that = (Id)o;
                return this.processId.equals(that.processId) &&
                this.sequencingMethodId.equals(that.sequencingMethodId);
            } else {
                return false;
            }
        }
        public int hashCode() {
            return processId.hashCode() + sequencingMethodId.hashCode();
        }
    }



Code:
*** Below is the spring:bind code which i would like to be able to bind to table C
<spring:bind path="process.sequencingMethods">
                <td>
                    <select name="${status.expression}" multiple size=3 style="width:200;">
                        <c:forEach var="sequencingMethod" items="${sequencingMethodList}" >
                            <c:forEach var="curSequencingMethod" items="${status.value}">
                                <c:if test="${curSequencingMethod.sequencingMethodId eq sequencingMethod.sequencingMethodId}">
                                    <c:set var="selected" value="true"/>
                                </c:if>
                            </c:forEach>
                            <option value="${sequencingMethod.sequencingMethodId}"
                                <c:if test="${selected}">selected="selected"</c:if>>${sequencingMethod.name}
                            </option>
                            <c:remove var="selected"/>
                        </c:forEach>
                    </select>
                </td>
                <td><font color="red"><c:out value="${status.errorMessage}"/></font></td>
                </spring:bind>


I am lost for a few days already on this and i sincerely hope that someone can guide me along on this. Thanks a million in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 6:08 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
I guess you should ask this question on the Spring forum instead. This seems more to be a spring related problem, so you'll have more chances to find competent people for Spring on the Spring forum directly.

HTH.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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

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.