chenrici
unread,Apr 4, 2011, 12:16:26 PM4/4/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mybatis-user, christop...@apg.ch
We are trying to map a composite key / id. We have a table A (mapped
to a class A) with a composite key consisting of two columns (b, c).
public class A {
private AId aId = new AId();
public AId getAId() {
return aId;
}
public void setAId(AId aId) {
this.aId = aId;
}
// ... more properties
}
public class AId {
private Long b;
private Long c;
// getters and setters, equals and hashcode
}
We tried to map as follows:
<resultMap id="resultMapA" type="A">
<id property="aId" column="{b=b,c=c}" />
</resultMap>
But this doesn't work. In the documentation we read "To deal with
composite keys, you can specify multiple column names to pass to the
nested select statement by using the syntax
column={prop1=col1,prop2=col2}. This will cause prop1 and prop2 to be
set against the parameter object for the target nested select
statement."
We are not quite sure, what select statement is meant, specially the
dtd of id doesnt allow "select" or "resultMap". Also we saw in the
source code that resultMap.getIdResultMappings is only referenced in
NestedResultSetHandler, but are not quite sure how our scenario we
come to NestedResultSetHandler.
Any help, hints or corrections of our assumptions are greatly
appreciated.
Christoph