JPA appengine subclass problem

java.lang.IllegalStateException: Field "cn.yuan.bean.Subclass" contains a persistable object that isnt persistent, but the field doesnt allow cascade-persist!
 at org.datanucleus.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:237)
 at org.datanucleus.jpa.EntityTransactionImpl.commit(EntityTransactionImpl.java:122)

 

当需要对一个子对象进行更新的时候,由于子对象有父对象的引用,可能产生这个异常.处理的方法如下:

     	TransactionExecutorFactory.getExecutor().execute(new TransactionRunner() {
			@Override
			public Object doIt() {
				subclass.setParent(null);//don't cascade parent object
				subclassDao.update(subclass);
				
	    		return null;

 

你可能感兴趣的:(java,bean,jpa)