Guten TagIbatis Vererbung und eine zu viele
Ich habe ein komplexes Modell (ddd), die ich mit Ibatis zuordnen möchte.
Mein Modell ist wie folgt:
class A {
int id;
String title;
List <B> b;
}
abstract class B {
int id;
String title;
List <C> f;
int type;
}
class BA extends B {
BA() {
setType(1);
}
}
class BB extends B {
BB {
setType(2);
}
}
Mein aktuelles XML-Mapping:
<sqlMap namespace="ABC">
<resultMap id="aResult" class="A" groupBy="a_id">
<result property="id" column=""a_id" />
<result property="title" column="a_title" />
<result property="b" resultMap="ABC.bResult" />
</resultMap>
<resultMap id="bResult" class="java.util.HashMap">
<discriminator javaType="java.lang.Integer" column="b_type">
<subMap value="1" resultMap="baResult" />
<subMap value="2" resultMap="bbResult" />
</discriminator>
</resultMap>
<resultMap id="baResult" class="BA">
<result property="id" column="b_id" />
<result property="title" column="b_title" />
</resultMap>
<resultMap id="bbResult" class="BB">
<result property="id" column="b_id" />
<result property="title" column="b_title" />
</resultMap>
<select id="aselect" resultMap="aResult">
select a.id as 'a_id', a.title as 'a_title', b.id as 'b_id', b.title as 'b_title', b.type as 'b_type'
from aa a left join bb b on a.id = b.aid
</select>
Tabellen
aa (
id int not null primary key,
title varchar(50) not null
)
bb (
id int not null primary key,
aid int not null,
title varchar(50) not null
type int not null
)
Die Vererbung funktioniert, aber es gibt nur eine in A (Äther BA oder BB) Event obwohl b ist eine Liste und es gibt mehrere Zeilen für b (BA, BB) Könnten Sie mir bitte helfen?
Der Grund für die Verwendung der BB & BB-Klassen ist, dass diese die separate Geschäftslogik (gemäß DDD) enthalten.
I ibatis 2.3.4.726 für java