私のSpring-Hibernateアプリケーションには、UserVO、BookVO、AttandanceVO、Timetableなどの4つのBeanクラスがあります。
そして私の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 は Timetable Id です。なぜ T2 が聞こえてくるのか、クエリに timetable が含まれていません..
それらのマッピングは必要ですか?
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
}