File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes javax.persistence.EntityNotFoundException: deleted entity passed to persist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "javax.persistence.EntityNotFoundException: deleted entity passed to persist" Watch "javax.persistence.EntityNotFoundException: deleted entity passed to persist" New topic
Author

javax.persistence.EntityNotFoundException: deleted entity passed to persist

Laura Barroso
Ranch Hand

Joined: Sep 21, 2009
Posts: 30
Hi, I have a OneToMay relationship in my project, and when I try to remove the side that holds the collection this exception arise:
javax.persistence.EntityNotFoundException: deleted entity passed to persist: [org.desoft.dcp.ag.entity.Block#<null>]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:598)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:513)
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269)

This is my code:
The first class has this code for the relation:

@OneToMany(mappedBy="block",fetch=FetchType.EAGER,cascade=CascadeType.ALL)
public Set<Field> getFields() {
return fields;
}

And the second:
@ManyToOne(optional = false)
@JoinColumns({
@JoinColumn(name = "enterprise_id", referencedColumnName = "enterprise_id", insertable = false, updatable = false),
@JoinColumn(name = "block_id", referencedColumnName = "block_id", insertable = false, updatable = false)
})
public Block getBlock() {
return block;
}

Laura Barroso
Ranch Hand

Joined: Sep 21, 2009
Posts: 30
working around this I have the idea of remove the entity through a query...this is my code:
String query="delete from Block block where block.blockPK.blockId='"+blockPk.getBlockId()+" ' and block.blockPK.enterpriseId=' "+ blockPk.getEnterpriseId()+" ' ";
application.getDataService().executeQuery(query, 1);

BlockPk represents my primary key...the problem now is this exception:

Caused by: javax.ejb.EJBException: java.lang.IllegalStateException: org.hibernate.hql.QueryExecutionRequestException: Not supported for DML operations [delete from org.desoft.dcp.ag.entity.Block block where block.blockPK.blockId='h' and block.blockPK.enterpriseId='cea']
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

could anyone help me ,please!!!
 
Don't get me started about those stupid light bulbs.
 
subject: javax.persistence.EntityNotFoundException: deleted entity passed to persist
 
Similar Threads
DAO hibernate/JPA, data missing
Composite Key
Table or view not found querying on subclass
Hibernate I18N Repeated column with composite IDs
(JPA) Correct way to remove entity ?