0 Replies Latest reply on Sep 14, 2005 9:48 AM by Sebastián Matienzo

    1 to N, Version and EJB 3 problem

    Sebastián Matienzo Newbie

      I'm working with EJB 3.0 RC1 and JBoss 4.0.2, and I have the following problem:

      I've got two Entity Beans: Father, Son; where the relationship is for 1 father, N sons. Between both of them, there's the following link:

      In the father:
      @OneToMany(cascade=CascadeType.ALL, mappedBy="father")
      private Collection sons = new HashSet();

      In the son:
      Father father;

      Also, in both entities, there's an attribute used for versioning by EJBs, defined as:

      private Long vers;

      When trying to persist a new father, no matter if it has sons or not, doing entityManager.persist(father) or entityManager.merge(father), throws me the following exception:

      ERROR [AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
      org.hibernate.AssertionFailure: dirty, but no dirty properties
      at org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:226)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:144)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:187)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:73)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:750)
      (I'll ommit the rest of the StackTrace).

      The strange thing is that, if I remove the @Version tag, all the entities are persisted correctly.
      On the other hand, if I retrieve an entity (entityManager.createQuery(...).getSingleResult()), modify it, and then
      persist it again, EJBs do it without any problems (even with the @Version tag).

      Any ideas where the problem might be? Thanks in advance.