Entity must be managed to call remove

1783 단어 DAOAOPxmlservletjpa
struts2.0 spring2.5  jpa              :
  : Servlet.service() for servlet default threw exception
java.lang.IllegalArgumentException: Entity must be managed to call remove: com.ctit.pojo.Student@1cd2197, try merging the detached and try the remove again.

나는 인터넷에서 오랫동안 찾았지만 해결 방법을 찾지 못했다.이제 내가 해결했어.
 
두 가지 원인이 있다.
  1.  dao  :
public void deleteStudent(Student student) {
   Student mergeStudent = this.getJpaTemplate().merge(student);
   getJpaTemplate().remove(mergeStudent);
}
    merge,      。

 
  2: applicationContext.xml     ,           。   service       。
<!-- ASPECT CONFIGURATION -->
	<aop:config>
		<aop:pointcut id="monsterManager" expression="execution(* com.ctit.service.*.*(..))" />
		<aop:advisor pointcut-ref="monsterManager" advice-ref="monsterAdvice"/>
	</aop:config>
	
	 
	<tx:advice id="monsterAdvice" transaction-manager="transactionManager">  
		<tx:attributes>
			<tx:method name="insert*" propagation="REQUIRED"/>
			<tx:method name="add*" propagation="REQUIRED"/>
			<tx:method name="update*" propagation="REQUIRED"/>
			<tx:method name="delete*" propagation="REQUIRED"/>
			<tx:method name="register*" propagation="REQUIRED"/>
			<tx:method name="create*" propagation="REQUIRED"/> 
			<tx:method name="*" />
		</tx:attributes>	
	</tx:advice>

좋은 웹페이지 즐겨찾기