如何在MyBatis 2中使用嵌入式类

时间:2019-09-16 11:29:00

标签: java mybatis spring-mybatis

实体:

@Table(name = "foo")
public class Foo {

    @Id
    @Column(name = "AccessPackage")
    private AccessPackage accessPackage;

    @Embedded
    private EmbeddedClass embed;

}

@Embeddable
public class EmbeddedClass {

    @Column(name = "url")
    private String url;

    @Column(name = "name")
    private String name;
}

SqlMap:

<sql id="domainObjectProperties" >#accessPackage#,#url#,#name#</sql>

<resultMap id="get-result" class="accessPackage" >
    <result property="url" column="url" javaType="String" />
    <result property="name" column="name" javaType="String" />
</resultMap>

加载sqlmap时会引发以下异常

There is no READABLE property named 'url' in class 'be.syntegro.syncore.common.domain.EmbeddedClass'

我不确定是否可以使用它,因为我在网上发现的信息很少

0 个答案:

没有答案