无法在java.lang.Integer和BINARY.- Spring之间进行转换

时间:2015-08-31 00:47:32

标签: java sql spring

我有以下用于将新记录保存到我的数据库的DTO

@Entity(name = "User")
public class User {

@Id
@Column(name = "User_Id")
private long userId;

@Column(name = "User_Name")
private String userNm;

@Column(name = "years_active")
private long years;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "Manager_Id", insertable = false, updatable = false)
private Manager manager;

@Column(name = "Projects",insertable = false, updatable = false)
private LinkedHashMap<Long, String> projects;

@Column(name = "Projects")
private long projectId;

@Column(name = "address")
private Address address;

//getters & setters

}

DDL:

CREATE TABLE [dbo].[User] (
[User_Id] int NOT NULL,
[User_Name] varchar(255) NOT NULL,
[years_active] int NOT NULL,
[Manager_id] int NOT NULL, //FK to Manager table
[Projects] int NOT NULL,   //FK to Project table
[Address] int NULL,        //FK to Address Table
[ModifiedBy] varchar(255) NOT NULL,
[ModifiedTS] datetime NULL)

通过表单提交将数据保存到此表没有问题,但是当我尝试使用Spring Repository检索实体对象时:

User user = userRepo.findOne(id); // id == Long, passed through @Controller method

我一直收到以下错误:Unable to convert between java.lang.Integer and BINARY.

o.h.engine.jdbc.spi.SqlExceptionHelper   : Unable to convert between java.lang.Integer and BINARY.
o.h.e.internal.DefaultLoadEventListener  : HHH000327: Error performing load command : 
org.hibernate.exception.DataException: Could not read entity state from ResultSet : EntityKey[com.myapp.entities.User#3]

我不确定整数和二进制之间的转换发生在哪里;任何想法?

0 个答案:

没有答案