我有MyBatis映射问题.
我有这样的域类:
public class MyClass
{
private Long id;
private Date create;
private String content;
MyClass (Long id, Date create, String content)
{
this.id = id;
this.create = create;
this.content = content;
}
//getters and setters
一个mapper类,其方法如下:
@Select("SELECT * FROM MyTable WHERE id=#{id}")
MyClass getMyClass (@Param("id") Long id);
在数据库中,三列的类型为Number,Timestamp和Clob,并且与类字段中的名称相同.
当我使用这种方法时,我得到一个:
ExecutorException:在[MyClass中找不到构造函数;匹配[java.math.BigDecimal,java.sql.Timestamp,oracle.jdbc.OracleClob]
但是,如果我从Myclass中删除构造函数,那么根本没有问题.我想有构造函数,我该如何修复它?
我尝试在mapper中添加@Results注释,但是没有任何区别:
@Results(value = {
@Result(column = "id", property = "id", javaType = Long.class),
@Result(column = "create", property = "create", javaType = Date.class),
@Result(column = "content", property = "content", javaType = String.class)
})