在我的Spring-Hibernate應用程序中,我有4個bean類,如UserVO,BookVO,AttandanceVO和Timetable。Hibernate異常:java.sql.SQLException:無效的值getInt() - 'T2'
和我AttendanceVO bean類:
@ManyToOne
@JoinColumn(name="BOOK_ID")
private BookVO book;
//Setters and getters.
和我BookVO bean類:
@ManyToOne
@JoinColumn(name = "USER_ID")
private UserVO user;
@ManyToOne
@JoinColumn(name = "Time_ID")
private TimeTable timetable;
//Setters and getters
在我的Hibernate類我正在寫查詢..
@Transactional
public List<AttendanceVO> findAttendanceList(UserVO user){
TypedQuery<AttendanceVO> query = entityManager.createQuery("select av from AttendanceVO av inner join av.book bb where bb.user=:user",
AttendanceVO.class);
query.setParameter("user", user);
return query.getResultList();
}
但我我得到異常像..
SEVERE: Servlet.service() for servlet [spring] in context with path [/EClass] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not load an entity: [com.sits.ec.valueObjects.BookVO#A2]] with root cause
java.sql.SQLException: Invalid value for getInt() - 'T2'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
..............
實際上是時間表身份證,爲什麼T2來聽說我要辦不包括在我的查詢時間表..
是他們的任何映射需要T2?
Edit 1:
@Entity
@Table(name = "BOOK")
public class BookVO{
@ManyToOne
@JoinColumn(name = "USER_ID")
private UserVO user;
@ManyToOne
@JoinColumn(name = "TIMETABLE_ID")
private TimetableVO timetable;
//Setters and getters
}
是的共享BookVO –
共享其他域類和基本表結構... – Thihara
與問題無關,但是,當您更改數據時,只應使用'@Transactional',不需要註釋時你只能選擇 –