玩1.3。 HibernateException:找到同一集合的两个表示

时间:2015-02-09 08:55:45

标签: java hibernate playframework-1.x

我在请求类中有字段文件的模型:

@Basic(fetch = FetchType.LAZY)
@ManyToMany
@JoinTable(name = "file2request",
        joinColumns = @JoinColumn(name = "request"),
        inverseJoinColumns = @JoinColumn(name = "file"))
public List<File> files = new ArrayList<>();

文件类中的映射:

@Basic(fetch = FetchType.LAZY)
@ManyToMany(mappedBy = "files", targetEntity = Request.class)
public List<Request> requests;

它在播放版 1.2.5.3 或更早版本上完美运行。但在版本 1.3.0 时,我保存请求时出错:

  

javax.persistence.PersistenceException:   org.hibernate.HibernateException:找到两个相同的表示   集合:models.base.requests.base.Request.files
  at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)     在   org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)     在org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:277)at at   models.base.requests.base.Request.setGeneratedUid(Request.java:543)     在models.base.requests.base.Request.lockedSetUid(Request.java:513)     在models.base.requests.base.Request.updateUid(Request.java:569)at   models.base.requests.kindergarten.KindergartenRequest.saveCore(KindergartenRequest.java:416)     在   models.base.requests.kindergarten.KindergartenRequest.saveRequestsCore(KindergartenRequest.java:300)     在   controllers.requests.types.Kindergarten.create(Kindergarten.java:217)     在   play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:524)     在play.mvc.ActionInvoker.invoke(ActionInvoker.java:475)at   play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:451)     在   play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:446)     在play.mvc.ActionInvoker.invoke(ActionInvoker.java:160)at   Invocation.HTTP请求(播放!)引起:   org.hibernate.HibernateException:找到两个相同的表示   集合:models.base.requests.base.Request.files at   org.hibernate.engine.internal.Collections.processReachableCollection(Collections.java:167)     在   org.hibernate.event.internal.FlushVisitor.processCollection(FlushVisitor.java:59)     在   org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:121)     在   org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:82)     在   org.hibernate.event.internal.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:76)     在   org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:175)     在   org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:251)     在   org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:100)     在   org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:61)     在   org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1130)     在   org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1747)     在   org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:232)     在org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:157)     在org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:268)...   另外12个

0 个答案:

没有答案