引起:javax.persistence.EntityNotFoundException:Bean已被删除 - 延迟加载失败

时间:2015-11-09 03:48:15

标签: playframework ebean

编辑:补充信息:

play.api.Application$$anon$1: Execution exception[[EntityNotFoundException: Bean has been deleted - lazy loading failed]]
2015-11-23T04:48:23.432891+00:00 app[web.1]:    at play.api.Application$class.handleError(Application.scala:296) ~[com.typesafe.play.play_2.10-2.3.7.jar:2.3.7]
 2015-11-23T04:48:23.432891+00:00 app[web.1]:   at play.api.DefaultApplication.handleError(Application.scala:402) [com.typesafe.play.play_2.10-2.3.7.jar:2.3.7]
2015-11-23T04:48:23.432893+00:00 app[web.1]:    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [com.typesafe.play.play_2.10-2.3.7.jar:2.3.7]
2015-11-23T04:48:23.432894+00:00 app[web.1]:    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [com.typesafe.play.play_2.10-2.3.7.jar:2.3.7]
2015-11-23T04:48:23.432895+00:00 app[web.1]:    at scala.Option.map(Option.scala:145) [org.scala-lang.scala-library-2.10.4.jar:na]
2015-11-23T04:48:23.432896+00:00 app[web.1]: Caused by: javax.persistence.EntityNotFoundException: Bean has been deleted - lazy loading failed
2015-11-23T04:48:23.432897+00:00 app[web.1]:    at com.avaje.ebean.bean.EntityBeanIntercept.loadBeanInternal(EntityBeanIntercept.java:516) ~[org.avaje.ebeanorm.avaje-ebeanorm-3.3.4.jar:na]
2015-11-23T04:48:23.432898+00:00 app[web.1]:    at com.avaje.ebean.bean.EntityBeanIntercept.loadBean(EntityBeanIntercept.java:480) ~[org.avaje.ebeanorm.avaje-ebeanorm-3.3.4.jar:na]
2015-11-23T04:48:23.432899+00:00 app[web.1]:    at com.avaje.ebean.bean.EntityBeanIntercept.preGetter(EntityBeanIntercept.java:583) ~[org.avaje.ebeanorm.avaje-ebeanorm-3.3.4.jar:na]
2015-11-23T04:48:23.432899+00:00 app[web.1]:    at models.Album._ebean_get_artist(Album.java:4)
2015-11-23T04:48:23.432900+00:00 app[web.1]:    at models.Album.getArtist(Album.java)

编辑:添加了影集定义的部分内容:

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@Column(length = 254)
@Constraints.MaxLength(254)
@NotNull
public String name;
@Column(name = "fullname", length = 254)
@Constraints.MaxLength(254)
@NotNull
public String fullName;
public Integer year;
@ManyToOne
@JoinColumn(name = "artist")
public Artist artist;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "album")
@OrderBy("name asc")
public List<Song> songs = Lists.newArrayList();
@OneToMany(fetch = FetchType.EAGER, mappedBy = "originalAlbum")
@OrderBy("name asc")
public List<Song> covers = Lists.newArrayList();

我看过EntityNotFoundException: Bean has been deleted - lazy loading failed

某处必定存在一些损坏的数据。但是,由于我正在使用的模型非常复杂,我不知道从哪里开始调试。

任何提示? (Play Framework 2.3,Avaje Ebean 3.1.1)升级到Play Framework 2.4,仍然是同一个问题。

1 个答案:

答案 0 :(得分:0)

以下是我用于查找ORM问题根本原因的过程:

  1. 识别症状中表达的实体;
  2. 识别与症状中表达的实体相关的实体;
  3. 识别相关实体(ies)ORM模型;
  4. 识别数据存储实体(ies)模型;和,
  5. 协调实体,ORM和数据模型。
  6. 将此流程映射到您的问题:

      堆栈跟踪中的
    1. 我们看到Album表示在症状中(即堆栈跟踪);
    2. 查看Album的实体定义,以识别与实体相关的身份;
    3. 对于每个相关实体,确定您的EBean ORM模型的表示方式;
    4. 对于每个实体,标识SQL模型;和,
    5. 从这些数据中,协调差异。
    6. 如评论中所述,您很可能遇到了ORM错误。如果可能的话,即使您不能在生产中执行此操作,也可能值得花时间升级到Play和EBean的最新稳定版本,即使您无法在生产中执行此操作。