2 Replies Latest reply on Aug 19, 2008 7:35 AM by jake j

    Exception on trying to persist more than one object

    jake j Newbie

      I get the following exception on trying to persist more than one bean object:


      Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.um2.mauction.entity.Enchere.bidder -> com.um2.mauction.entity.Utilisateur
      at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:353)
      at org.hibernate.engine.Cascade.cascade(Cascade.java:139)
      at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
      at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
      at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
      ... 48 more


      The objects to be added are related to each other via foreign keys so I'm guessing it's because a dependent object can't find the parent object in the database (which is getting persisted just above in the same function). Anyway to remedy this behaviour?