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.
我在网上找了很长时间,但是没有找到解决办法。现在被我解决了。
有2种原因造成的:
原因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>
分享到:
相关推荐
实现linq多个查询条件连接功能(支持linq to sql 和linq to entity)。 按多个指定属性排序功能。 不同参数的lamdba表达式条件间的转换功能。
C#:此小程序实现将复杂的 json 格式数据转换为对应的实体类对象,对象与对象之间的关系采用了 ImplementFactory 组件提供的 Constraint 属性,可以在 Visual Studio 里使用 Nuget 搜索并引用该组件,该组件可实现...
org.apache.http的相关类,...> ★HttpEntity cannot be resolved to a type > ★EntityUtils cannot be resolved > ★HttpResponse cannot be resolved to a type > ★DefaultHttpClient cannot be resolved to a type
数据库连接 Linq to Entity
LINQ to SQL和Entity Framework对比与关联LINQ to SQL和Entity Framework对比与关联
对于linq to entity的语法的介绍以北风网为例子
Entity Framework技术系列之7:LINQ to Entities.pdf
You will then be taught to improve and develop Entity Framework in complex business scenarios. With the concluding chapter on performance and scalability, this book will get you ready to use Entity ...
Armed with this experience, you will be ready to dive deep into Entity Framework, experiment with new approaches, and develop ways to solve even the most difficult data access challenges. If you are ...
By the end of the book, you will be able to successfully extend the new functionalities of Entity framework into your project. Style and approach This book is a step-by-step tutorial providing hands...
Model, map, and access data effectively with Entity Framework Core 2, the latest evolution of Microsoft’s object-relational mapping framework that allows developers to access data using .NET objects,...
edition of Programming Entity Framework was dedicated to teaching readers how to use this version of Entity Framework in Visual Studio 2010. When .NET 4 was released, the Entity Framework team was ...
MVC+Linq to Entity音乐商店源码 功能介绍: 简单实现了音乐商品的管理和分类查看功能
Data access is an integral part of any ... You'll learn how to retrieve data by querying the Entity Data Model and understand how to use LINQ to Entities and Entity SQL to query the Entity Data Model.
For two tables to be union compatible, the tables should be the same with respect to which of the following? (a) keys (b) cardinality (c) name (d) degree Correct answer is (d) Your ...
You will see how LINQ can be used with Entity Framework to give you access to stored data. You will then learn how to use Entity Framework to persist information in a Relational Database Management ...
edition of Programming Entity Framework was dedicated to teaching readers how to use this version of Entity Framework in Visual Studio 2010 When NET 4 was released the Entity Framework team was ...
实现CSV到C#类的转化,读取。用代码生成器,自动生成CSV类。用附加属性的方法,定义CSV类。匹配CVS类和CVS文件,并读取数据。
You will be guided to create six WCF and Entity Framework solutions from scratch, of which three are multi-layered real-world WCF service solutions, so you will not only be reading, but also be ...
You will then be taught to improve and develop Entity Framework in complex business scenarios. With the concluding chapter on performance and scalability, this book will get you ready to use Entity ...