0
是否有可能映射在一个查询即使用MyBatis的注解嵌入对象:
Foo类: 的MyBatis - constructorArgs注释和嵌入对象
public class Foo //immutable
{
private final Integer fooId;
private final String fooAttr;
private final Bar bar;
public Foo(Integer fooId, String fooAttr, Bar bar) //constructor
}
酒吧类:
public class Bar { //immutable
private final Integer barId;
private final String barAttr;
public Bar(Integer barId, String barAttr) //constructor
}
表FooBar的:
- INT foo_id
- CHAR foo_attr
- INT bar_id
- CHAR bar_attr
查询:
@ConstructorArgs({
@Arg(column="foo_id", javaType=Integer.class),
@Arg(column="foo_attr", javaType=String.class),
Bar ?
})
Select("select * from FooBar where foo_id=#{fooId}"
public Foo getFooBy(@Param("fooId") Integer fooId);
如何将Bar类映射为Foo构造函数参数(不使用子查询)?