Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在spring jdbctemplate中将实体映射到行映射器时发生异常_Java_Spring - Fatal编程技术网

Java 在spring jdbctemplate中将实体映射到行映射器时发生异常

Java 在spring jdbctemplate中将实体映射到行映射器时发生异常,java,spring,Java,Spring,我在JPA中有一个如下所示的实体对象 @Entity @Table(name="my_version") public class MyVersion implements EntityKeyOverride { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") private Long id; @NotNull private Long instan

我在JPA中有一个如下所示的实体对象

@Entity
@Table(name="my_version")
public class MyVersion implements EntityKeyOverride {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;

    @NotNull
    private Long instanceId;

    @NotNull
    private Long documentId;

    @NotNull
    @Size(max = 255)
    private String name;


    @NotNull
    private Integer majorVersion;


    @NotNull
    private Integer minorVersion;

    @Size(max = 255)
    private String classification;

    @Size(max = 1500)
    private String description;

    @Size(max = 1500)
    private String title;

    @Size(max = 255)
    private String lifecycle;


    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "LL", iso = ISO.DATE_TIME)
    private Calendar createdDate;

//getter and setter

}
我正在尝试从hibernate/jpa entitymanager转移到jdbctemplate。我正在尝试将我的实体用作BeanPropertyRowMapper,而不是Customrowmapper

jdbcTemplate.query(SQLQueryDescriptorTest, query.toString(), parameterMap, new BeanPropertyRowMapper(MyVersion.class));
对于这一点,我几乎没有什么疑问

1) 如果我使用BeanPropertyRowMapper或CustomRowMapper,注释会像
@NotNull@Size(max=255)
一样应用吗?因为我正在远离实体

2) 当使用BeanPropertyRowMapper时,我得到以下异常

caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [java.sql.Timestamp] to required type [java.util.Calendar] for property 'createdDate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.sql.Timestamp] to required type [java.util.Calendar] for property 'createdDate': no matching editors or conversion strategy found
        at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:591)
        at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:603)
        at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:449)

日历
更改为
日期
,并删除
@Temporal
@DateTimeFormat
注释