【发布时间】:2018-07-18 15:05:59
【问题描述】:
我正在将一部电影添加到基本 MovieEntity 类,然后是另一个标题 MovieOtherEnity 继承自 MovieInfoEntity 的类
MovieInfoEntity 有一个指向MovieEntity 的外键。 MovieEntity 具有继承自 MovieInfoEntity 类的实体列表。
我有一个测试,每次测试后都会清除基地中的物体。
/**
* Clean out the db after every test.
*/
@After
public void cleanup() {
this.contributionRepository.deleteAll();
this.messageRepository.deleteAll();
this.movieRepository.deleteAll(); // here he throws an exception
this.movieInfoRepository.deleteAll();
this.userRepository.deleteAll();
}
上面代码中标记的行被抛出
org.springframework.orm.ObjectRetrievalFailureException: Object [id=1] was not of the specified subclass [com.jonki.popcorn.core.jpa.entity.movie.MovieBoxOfficeEntity] : loaded object was of wrong class class com.jonki.popcorn.core.jpa.entity.movie.MovieOtherTitleEntity; nested exception is org.hibernate.WrongClassException: Object [id=1] was not of the specified subclass [com.jonki.popcorn.core.jpa.entity.movie.MovieBoxOfficeEntity] : loaded object was of wrong class class com.jonki.popcorn.core.jpa.entity.movie.MovieOtherTitleEntity
我会提到它测试方法,我将 Object MovieOtherTitle 项添加到 MovieEntity 对象的列表中。
【问题讨论】:
标签: java spring spring-mvc spring-boot