implement distributed transations management in the campus system zhuo zeng

Post on 26-Dec-2015

223 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Implement distributed transations Management in the Campus Syste

mZhuo Zeng

Layers

Three layers:

1. Presentation Layer

2. Application Layer

3. Data Mapping Layer

Database

• 3 tables:

Data-Mapping

• <hibernate-mapping>• <class name="com.zz.po.User" table="[USER]" >• <id name="userid" type="java.lang.Long">• <column name="userid" />• <generator class="identity" />• </id>• <property name="username" type="java.lang.String">• <column name="username" />• </property>• <property name="password" type="java.lang.String">• <column name="password" />• </property>• <property name="truename" type="java.lang.String">• <column name="truename" />• </property>• <property name="birthday" type="java.lang.String">• <column name="birthday" />• </property>• <property name="telephone" type="java.lang.String">• <column name="telephone" />• </property>• <property name="email" type="java.lang.String">• <column name="email" />• </property>• <property name="usertype" type="java.lang.Integer">• <column name="usertype" />• </property>• <property name="lock" type="java.lang.Integer">• <column name="lock" />• </property>• </class>• </hibernate-mapping>

Strust+Spring+Hibernate

Connection Pool

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" p:driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"p:jdbcUrl="jdbc:sqlserver://localhost:1433;databaseName=Admin"

p:user="sa" p:password="123456" p:maxPoolSize="40" p:minPoolSize="1"

p:initialPoolSize="1" p:maxIdleTime="20" />

Transaction

The simplistic view of a transaction issued to the database using SQL is as follows:

1. Begin the transaction using begin transaction command.

2. Perform various deleted, update or insert operations using SQL queries.

3. If all the operation are successful then perform commit otherwise rollback all the operations.

Transaction

• </bean>• <bean class="org.springframework.transaction.interceptor.TransactionInter

ceptor" id="transactionInterceptor">• <property name="transactionManager" ref="transactionManager"/>• <property name="transactionAttributes">• <props>• <prop key="add*">PROPAGATION_REQUIRED</prop>• <!--PROPAGATION_REQUIRED:Support a current transaction; create a new one if none exists.!->

• <prop key="modify*">PROPAGATION_REQUIRED</prop>• <prop key="update*">PROPAGATION_REQUIRED</prop>• <prop key="log*">PROPAGATION_REQUIRED</prop>• <prop key="*">PROPAGATION_SUPPORTS,readOnly</prop>• <!--PROPAGATION_SUPPORTS:Support a current transaction, execute non-transactionally if none exists.!-->

• </props>• </property>• </bean>

Login

Administrator

Student Management

Teacher Management

Course Management

Teacher Management System

Student Management System

top related