-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: helpEntityNotFoundException deleted entity passed to persist
PostPosted: Mon Jan 12, 2009 10:50 pm 
Newbie

Joined: Tue Nov 25, 2008 9:31 pm
Posts: 18
Hi,

I am trying to remove Experiment but I am stuck with this error, please help I tried various options ..:(

Error:----------------------
ERROR [application] javax.persistence.EntityNotFoundException: deleted entity passed to persist: [com.entity.ExperimentHistoryRecords#<null>]
javax.faces.el.EvaluationException: javax.persistence.EntityNotFoundException: deleted entity passed to persist: [com.entity.ExperimentHistoryRecords#<null>]
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
----------------------

ExperimentHome.java
-------------------
Code:
public String remove(){   
   super.getInstance().getProject().getQuantExperiment().remove(getInstance());
   return super.remove();
}


Experiment.java entity----------------------
Code:
@Entity(name = "Experiment")
public class Experiment implements Equals, HashCode, ToString
{
   
   protected List<ExperimentHistoryRecords> ExperimentHistoryRecords;
   protected Project project;

   @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY, mappedBy="Experiment")
   public List<ExperimentHistoryRecords> getExperimentHistoryRecords() {
        if (ExperimentHistoryRecords == null) {
            ExperimentHistoryRecords = new ArrayList<ExperimentHistoryRecords>();
        }
        return this.ExperimentHistoryRecords;
   }

   public void setExperimentHistoryRecords(List<ExperimentHistoryRecords> ExperimentHistoryRecords) {
       for(ExperimentHistoryRecords qehr : ExperimentHistoryRecords){
          qehr.setQuantExperiment(this);
       }
        this.ExperimentHistoryRecords = ExperimentHistoryRecords;
    }

   @ManyToOne(fetch = FetchType.LAZY, optional=false)
   public Project getProject() {
      return project;
   }

   public void setProject(Project project) {
      this.project = project;
   }
   ....
}


ExperimentHistoryRecords.java entity
------------------------------------
Code:
@Entity(name = "ExperimentHistoryRecords")
public class ExperimentHistoryRecords implements Equals, HashCode, ToString
{
   protected Experiment Experiment;
   protected Project project;

   @ManyToOne(fetch = FetchType.LAZY, optional=false)
    public Experiment getQuantExperiment() {
        return Experiment;
    }

   public void setQuantExperiment(Experiment value) {
        this.Experiment = value;
    }

   @ManyToOne(fetch = FetchType.LAZY, optional=false)
    public Project getProject() {
        return project;
    }

   public void setProject(Project value) {
        this.project = value;
    }


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2009 3:54 am 
Newbie

Joined: Tue Jan 13, 2009 3:13 am
Posts: 2
how does ExperimentHome's superclass implement remove method?


Top
 Profile  
 
 Post subject: helpEntityNotFoundException deleted entity passed to persist
PostPosted: Tue Jan 13, 2009 8:33 am 
Newbie

Joined: Tue Nov 25, 2008 9:31 pm
Posts: 18
Thanks for replying, we are using Seam and ExperimentHome uses EntityHome and EntityHome extends EntityManager.

Here is the code snippet... pls suggest

ExperimentHome.java-------------------
Code:
public class ExperimentHome extends EntityHome<Experiment> {
....
public String remove(){

   super.getInstance().getProject().getExperiment().remove(getInstance());
   return super.remove();
}


Seam API EntityHome
-------------------
Code:
public class EntityHome<E> extends Home<EntityManager, E>{
   .....
@Transactional
   public String remove()
   {
      getEntityManager().remove( getInstance() );
      getEntityManager().flush();
      deletedMessage();
      raiseAfterTransactionSuccessEvent();
      return "removed";
   }
}


Top
 Profile  
 
 Post subject: helpEntityNotFoundException deleted entity passed to persist
PostPosted: Fri Jan 16, 2009 12:31 pm 
Newbie

Joined: Tue Nov 25, 2008 9:31 pm
Posts: 18
Any suggestion, I should try for the above issue.... stuck :(


Top
 Profile  
 
 Post subject: EntityNotFoundException deleted entity passed to persist
PostPosted: Tue Feb 10, 2009 10:05 pm 
Newbie

Joined: Tue Nov 25, 2008 9:31 pm
Posts: 18
Here is more clear output, please suggest, what else I can try...

It is very important, I will be very thankful for any suggestion....

Issue : When I try to remove QuantExperiment entity, using quantExperimentHome.remove(), I get the following error.
Error:
------
INFO [STDOUT] CHECK, QuantExperimentHistoryRecords HJID is = 665, and QuantExperiment HJID is : 303
INFO [STDOUT] CHECK, QuantExperimentHistoryRecords HJID is = 666, and QuantExperiment HJID is : 303

ERROR [application] javax.persistence.EntityNotFoundException: deleted entity passed to persist: [com.entity.QuantExperimentHistoryRecords#<null>]
javax.faces.el.EvaluationException: javax.persistence.EntityNotFoundException: deleted entity passed to persist: [com.entity.QuantExperimentHistoryRecords#<null>]
.....................

--For testing I am printing the id of both the entities in remove(), which is displayed in log above.

--Note : We are using "super.getInstance().getProject().getQuantExperiment().remove(getInstance());" else it will give the same error for QuantExperiment.
i.e. "javax.persistence.EntityNotFoundException: deleted entity passed to persist: [com.entity.QuantExperiment#<null>]"

Please help on the following error, I have tried various options but no success :(

[
Code:
b]QuantExperimentHome.java[/b
public String remove(){
   ////JUST TO CHECK////
List<QuantExperimentHistoryRecords> qeHr= getInstance().getQuantExperimentHistoryRecords();
int xs=qeHr.size();
for(int i=0;i<xs;i++){
  QuantExperimentHistoryRecords qeg=qeHr.get(i);
  //entityManager.remove(qeg); // TRIED THIS ALSO
  System.out.println("CHECK, QuantExperimentHistoryRecords HJID is = "+qeg.getHjid()+", and QuantExperiment HJID is : "+qeg.getQuantExperiment().getHjid());
}
////END CHECK////

super.getInstance().getProject().getQuantExperiment().remove(getInstance());
return super.remove();
}


Code:
@Entity(name = "QuantExperiment")
public class QuantExperiment implements Equals, HashCode, ToString
{
protected List<QuantExperimentHistoryRecords> quantExperimentHistoryRecords;
protected Project project;

@OneToMany(cascade = {CascadeType.ALL},fetch = FetchType.LAZY, mappedBy="quantExperiment")
public List<QuantExperimentHistoryRecords> getQuantExperimentHistoryRecords() {
  if (quantExperimentHistoryRecords == null) {
   quantExperimentHistoryRecords = new ArrayList<QuantExperimentHistoryRecords>();
  }
  return this.quantExperimentHistoryRecords;
}

@ManyToOne(fetch = FetchType.LAZY, optional=false)
public Project getProject() {
  return project;
}
}


Code:
@Entity(name = "QuantExperimentHistoryRecords")
public class QuantExperimentHistoryRecords implements Equals, HashCode, ToString {
   protected Project project;
protected QuantExperiment quantExperiment;

@ManyToOne(fetch = FetchType.LAZY, optional=false)
public QuantExperiment getQuantExperiment() {
  return quantExperiment;
}

@ManyToOne(fetch = FetchType.LAZY, optional=false)
public Project getProject() {
  return project;
}
}


Code:
@Entity(name = "Project")
public class Project implements Equals, HashCode, ToString
{
protected List<QuantExperiment> quantExperiment;
protected List<QuantExperimentHistoryRecords> quantExperimentHistoryRecords;

@OneToMany(cascade = {CascadeType.ALL},fetch=FetchType.LAZY, mappedBy="project")
    public List<QuantExperiment> getQuantExperiment() {
        if (quantExperiment == null) {
            quantExperiment = new ArrayList<QuantExperiment>();
        }
     return this.quantExperiment;
    }

@OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY, mappedBy="project")
    public List<QuantExperimentHistoryRecords> getQuantExperimentHistoryRecords() {
        if (quantExperimentHistoryRecords == null) {
            quantExperimentHistoryRecords = new ArrayList<QuantExperimentHistoryRecords>();
        }
        return this.quantExperimentHistoryRecords;
    }
}


Top
 Profile  
 
 Post subject: Re: helpEntityNotFoundException deleted entity passed to persist
PostPosted: Wed May 27, 2009 7:12 am 
Newbie

Joined: Fri May 22, 2009 1:07 pm
Posts: 2
Hi valatharv,
Have you found a solution for this error.
Can you share it with me.
I too am getting the same issue and is driving me nuts.
thanks
Neeraj


Top
 Profile  
 
 Post subject: Re: helpEntityNotFoundException deleted entity passed to persist
PostPosted: Sun May 31, 2009 3:51 am 
Newbie

Joined: Tue Nov 25, 2008 9:31 pm
Posts: 18
Hi Neeraj,

No, I was not able to find solution for it, I tried sometime back as it was not of high priority we left it...

But, I will try the same later... I understand it drives crazy...

Let me know if you come across the solution, I will also post if I find any.

Regards


Top
 Profile  
 
 Post subject: Re: helpEntityNotFoundException deleted entity passed to persist
PostPosted: Tue Jun 16, 2009 8:18 am 
Beginner
Beginner

Joined: Thu Apr 17, 2008 5:47 pm
Posts: 26
hi guys,

I think I have found it.
If you have for example Order->OrderLine (OneToMany)
and you execute:
em.remove(orderLine);
em.flush() / em.commit() // the exception is thrown here

if you do:
(1)
order.getOrderLines().remove(orderLine)
em.remove(orderLine);
em.flush() / em.commit() // no problems

or
(2)
em.remove(orderLine);
order.getOrderLines().remove(orderLine)
em.flush() / em.commit() // no problems

.. seems that fixing the relation in memory before flush/commit is the solution


Top
 Profile  
 
 Post subject: Re: helpEntityNotFoundException deleted entity passed to persist
PostPosted: Wed Jul 08, 2009 3:47 pm 
Newbie

Joined: Tue Nov 25, 2008 9:31 pm
Posts: 18
Hi Bodrin,

Good to know that you found a solution...

It will be nice if you can suggest on my above post starting with "Here is more clear output, please suggest, what else I can try..." it contains all information of entity mapping


Top
 Profile  
 
 Post subject: Re: helpEntityNotFoundException deleted entity passed to persist
PostPosted: Mon Jul 20, 2009 11:02 am 
Beginner
Beginner

Joined: Thu Apr 17, 2008 5:47 pm
Posts: 26
Hi valatharv,

If we assume that the exception

"javax.persistence.EntityNotFoundException: deleted entity passed to persist"

is thrown in all cases for the same problem, then your problem should be the same
and the solution:

You probably have to fix all the in memory relations to the deleted entity before flush/commit time.

I have no other idea and don't know if there can be different causes while the same exception is thrown... hope this will help


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.