Transactionproxyfactorybean configuration problems

Source: Internet
Author: User
<? XML version = "1.0" encoding = "UTF-8"?>
<Beans xmlns = "http://www.springframework.org/schema/beans"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xmlns: context = "http://www.springframework.org/schema/context"
Xmlns: AOP = "http://www.springframework.org/schema/aop"
Xmlns: Tx = "http://www.springframework.org/schema/tx"
Xsi: schemalocation = "http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
Http://www.springframework.org/schema/context
Http://www.springframework.org/schema/context/spring-context-2.5.xsd
Http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd ">

<Context: annotation-config/>
<Context: component-scan base-package = "com. *"/>

<Bean id = "sessionfactory"
Class = "org. springframework. Orm. hibernate3.localsessionfactorybean">
<Property name = "configlocation" value = "classpath: hibernate. cfg. xml"/>
<Property name = "configurationclass" value = "org. hibernate. cfg. annotationconfiguration"/>
</Bean>

<! -- Define the Transaction Manager (declarative transaction) -->
<Bean id = "transactionmanager"
Class = "org. springframework. Orm. hibernate3.hibernatetransactionmanager">
<Property name = "sessionfactory" ref = "sessionfactory"/>
</Bean>

<! -- Configure Dao -->
<Bean id = "generatordaotarget" class = "com. *. Spring. Dao. generatordaoimpl">
<Property name = "sessionfactory" ref = "sessionfactory"/>
</Bean>

<Bean id = "generatordao"
Class = "org. springframework. transaction. Interceptor. transactionproxyfactorybean">
<! -- Configure the Transaction Manager -->
<Property name = "transactionmanager"> <ref bean = "transactionmanager"/> </property>
<Property name = "target"> <ref bean = "generatordaotarget"/> </property>
<Property name = "proxyinterfaces"> <value> com. *. Spring. Dao. generatordao </value> </property>
<! -- Configure transaction properties -->
<Property name = "transactionattributes">
<Props>
<Prop key = "*"> propagation_required </prop>
</Props>
</Property>
</Bean>

<Bean id = "plantdaotarget" class = "com. *. Spring. Dao. plantdaoimpl">
<Property name = "sessionfactory" ref = "sessionfactory"/>
</Bean>

<Bean id = "plantdao"
Class = "org. springframework. transaction. Interceptor. transactionproxyfactorybean">
<! -- Configure the Transaction Manager -->
<Property name = "transactionmanager"> <ref bean = "transactionmanager"/> </property>
<Property name = "target"> <ref bean = "plantdaotarget"/> </property>
<Property name = "proxyinterfaces"> <value> com. *. Spring. Dao. plantdao </value> </property>
<! -- Configure transaction properties -->
<Property name = "transactionattributes">
<Props>
<Prop key = "*"> propagation_required </prop>
</Props>
</Property>
</Bean>

<! -- Configure service -->
<Bean id = "plantgeneratorservicetarget"
Class = "com. *. Spring. Service. plantgeneratorserviceimpl">
<Property name = "plantdao">
<Ref bean = "plantdao"/>
</Property>
<Property name = "generatordao">
<Ref bean = "generatordao"/>
</Property>
</Bean>

<Bean id = "plantgeneratorservice"
Class = "org. springframework. transaction. Interceptor. transactionproxyfactorybean">
<! -- Configure the Transaction Manager -->
<Property name = "transactionmanager"> <ref bean = "transactionmanager"/> </property>
<Property name = "target"> <ref bean = "plantgeneratorservicetarget"/> </property>
<Property name = "proxyinterfaces"> <value> com. *. Spring. Service. plantgeneratorservice </value> </property>
<! -- Configure transaction properties -->
<Property name = "transactionattributes">
<Props>
<Prop key = "*"> propagation_required </prop>
</Props>
</Property>
</Bean>
</Beans> <? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype hibernate-configuration public
"-// Hibernate/hibernate configuration DTD 3.0 // en"
Http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd>

<Hibernate-configuration>

<Session-factory>

<! -- Configure Attributes -->
<! -- True indicates that the SQL statement sent by hibernate to the database is displayed. -->
<Property name = "hibernate. show_ SQL"> true </property>
<Property name = "hibernate. hbm2ddl. Auto"> none </property>

<! -- SQL dialect. MySQL is set here -->
<Property name = "dialect"> org. hibernate. dialect. mysqldialect </property>
<! -- Connect to the database driver -->
<Property name = "connection. driver_class"> com. MySQL. JDBC. Driver </property>
<! -- Database connection URL -->
<Property name = "connection. url"> JDBC: mysql: // localhost: 3306/test </property>

<! -- Username -->
<Property name = "connection. username"> root </property>
<! -- Password -->
<Property name = "connection. Password"> 123456 </property>

<! -- Ing file -->
<Mapping class = "com. *. Spring. domain. generator"/>
<Mapping class = "com. *. Spring. domain. Plant"/>
</Session-factory>
</Hibernate-configuration> Public interface generatordao {

/**
* Obtain data of all units
* @ Return
*/
Public list <generator> listgenerators ();

/**
* Save unit data
* @ Param Generator Unit data
*/
Public void save (generator );
} Public class generatordaoimpl extends hibernatedaosupport implements generatordao {

@ Suppresswarnings ("unchecked ")
Public list <generator> listgenerators (){
Return this. getsession (). createquery ("from generator"). List ();
}

Public void save (generator ){
This. getsession (). Save (generator );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.