Struts + Hibernate: @SessionTarget not working

三世轮回 提交于 2019-11-27 05:13:27

If you want to use the Hibernate Session and Transaction injection capability, your action mapping package need to extend the package hibernate-default.

More details about hibernate-default package

The plugin provides a mapping package called hibernate-default. And this has three interceptor stacks indicated for injection capabilities:

  • basicStackHibernate: Like Struts2basickStack (NO validations!), but with Hibernate session and transaction injections capability.

  • defaultStackHibernate: Like Struts2 defaultStack, but without Struts2 validation methods (annotation and XML). Uses Hibernate Validation framework instead.

  • defaultStackHibernateStrutsValidation: Struts2 defaultStack+ plugin's basicStackHibernate.

This package extends the hibernate-default package, so all default Struts2 configurations can be used if you need.

hibernate-default package is abstract, so you can extends this with other. For example:

<package name="default" extends="hibernate-default,json-default" >

To use hibernate-default with an annotation configuration use

@ParentPackage("hibernate-default")
@InterceptorRef("basicStackHibernate")
public class YourAction extends ActionSupport {}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!