用实例见证smartclient的厉害吧。
先貼出來圖片 炫炫!很閃吧。
建表語句:
create table supplyItem(
itemID int primary key identity(1,1),
itemName varchar(300),
unitCost decimal(28,2), --55.23
SKU varchar(30),
description varchar(5000),
category varchar(128),
inStock varchar(30),
units varchar(30),
nextShipment datetime
)
--drop table supplyCategory
create table supplyCategory(
categoryName varchar(128) primary key,
parentID varchar(255),
)
demoAppJS.jsp
Jsp代碼:
<!--------------------------------------------------------------------
整合人:舒婷 *_*
---------------------------------------------------------------------->
<HTML>
<HEAD>
<TITLE>SmartClient Demo Application</TITLE>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<SCRIPT>var isomorphicDir="isomorphic/";</SCRIPT>
<SCRIPT SRC=smartclient/modules/ISC_History.js></SCRIPT>
<SCRIPT SRC=smartclient/modules/ISC_Core.js></SCRIPT>
<SCRIPT SRC=smartclient/modules/ISC_Foundation.js></SCRIPT>
<SCRIPT SRC=smartclient/modules/ISC_Containers.js></SCRIPT>
<SCRIPT SRC=smartclient/modules/ISC_Grids.js></SCRIPT>
<SCRIPT SRC=smartclient/modules/ISC_Forms.js></SCRIPT>
<SCRIPT SRC=smartclient/modules/ISC_DataBinding.js></SCRIPT>
<SCRIPT SRC=smartclient/modules/load_skin.js></SCRIPT>
</HEAD>
<BODY CLASS="pageBackground" STYLE="overflow:hidden">
<script src="demoAppJS.js"></script>
</BODY>
</HTML>
demoAppJS.js
isc.setAutoDraw(false);
//<isomorphic:loadDS name="supplyItem"/>
//<isomorphic:loadDS name="supplyCategory"/>
isc.DataSource.create({
ID:"supplyCategory",
dataFormat:"xml",
recordXPath:"//country",
fields:[
{name:"categoryName",primaryKey:true},
{foreignKey:"supplyCategory.categoryName",//这一步 不懂、??
hidden:true,
name:"parentID",
required:true,
rootValue:"root", //初始化加载parentID为root记录 如果没有设置rootValue 会出现死循环式的树
type:"text"
}
],
operationBindings:[
{
operationType:"fetch",
dataURL:"demoApp/findTreeAll.action"
}
]
});
isc.DataSource.create({
ID:"supplyItem",
dataFormat:"xml", //数据格式 xml格式
recordXPath:"//country", //--<country></country>
fields:[
//{name:"itemId",primaryKey:true},//countryCode設置為主鍵
{name:"itemName", title:"itemName"},
{name:"unitCost", title:"unitCost"},
{name:"SKU",title:"SKU"},
{name:"description",title:"description"},
{name:"category",title:"category"},
{name:"inStock",title:"inStock"},
{name:"nextShipment",title:"nextShipment"}
],
operationBindings:[
{operationType:"fetch",
dataURL:"demoApp/findAll.action"
},
{operationType:"add"
//dataURL:"country/insertInfo.action"
},
{operationType:"update"
//dataURL:"country/updateInfo.action"
},
{operationType:"remove"
//dataURL:"country/deleteInfo.action"
}
]
});
isc.Page.setAppImgDir(isc.Page.getIsomorphicDocsDir()+"exampleImages/"); //设置img文件路径
isc.TreeGrid.create({
ID:"categoryTree",
dataSource:"supplyCategory",
nodeClick:"findForm.findItems(node.categoryName)",
showHeader:false,
leaveScrollbarGap:false,
animateFolders:true,
canAcceptDroppedRecords:true,
canReparentNodes:false,
selectionType:"single",
animateRowsMaxTime:750
});
isc.HTMLPane.create({
ID:"helpCanvas",
contentsURL:"demoApp_helpText.html",
overflow:"auto",
styleName:"defaultBorder",
padding:10
});
isc.IButton.create({
ID:"findButton",
title:"Find",
left:25,
top:16,
width:80,
click:"findForm.findItems()",
icon:"demoApp/icon_find.png",
iconWidth:24
});
isc.SearchForm.create({
ID:"findForm",
dataSource:supplyItem,
left:130,
top:10,
cellPadding:4,
numCols:6,
fields:[
{name:"SKU"},
{name:"itemName", editorType:"comboBox", optionDataSource:"supplyItem",
pickListWidth:250},
{name:"findInCategory", editorType:"checkbox",
title:"Use category", defaultValue:true, shouldSaveValue:false}
],
// Function to actually find items
findItems : function (categoryName) {
var findValues;
if (this.getValue('findInCategory') && categoryTree.selection.anySelected()) {
// use tree category and form values
if (categoryName == null) categoryName = categoryTree.getSelectedRecord().categoryName;
findValues = {category:categoryName};
isc.addProperties(findValues, this.getValues());
} else if (categoryName == null) {
// use form values only
findValues = this.getValues();
} else {
// use tree category only
findValues = {category:categoryName};
}
itemList.filterData(findValues);
itemDetailTabs.clearDetails();
}
});
isc.ListGrid.create({
ID:"itemList",
dataSource:supplyItem,
useAllDataSourceFields:true,
fields:[
{name:"itemName", title:"Name", showHover:true},
{name:"unitCost",
formatCellValue:"return isc.Format.toCurrencyString(parseFloat(value))",
editorType:"spinner", editorProperties:{step:0.01}},
{name:"SKU", canEdit:false},
{name:"description", showHover:true},
{name:"category", canEdit:false},
{name:"inStock", width:55, align:"center",
formatCellValue : function (value, record, field, rowNum, colNum) {
if (value) return isc.Canvas.imgHTML("demoApp/checked.png",13,13);
else return isc.Canvas.imgHTML("demoApp/unchecked.png",13,13)
}},
{name:"nextShipment", showIf:"false"}
],
recordClick:"this.updateDetails()",
canEdit:true,
modalEditing:true,
cellChanged:"this.updateDetails()",
alternateRecordStyles:true,
canDragRecordsOut:true,
hoverWidth:200,
hoverHeight:20,
selectionType:"single",
cellContextClick:"return itemListMenu.showContextMenu()",
updateDetails : function () {
var record = this.getSelectedRecord();
if (record == null) return itemDetailTabs.clearDetails();
if (itemDetailTabs.getSelectedTabNumber() == 0) { itemViewer.setData(record)
} else {
itemDetailTabs.updateTab("editTab", editForm);
editForm.editRecord(record);
}
}
});
isc.Menu.create({
ID:"itemListMenu",
cellHeight:22,
data:[
{title:"Add New Item",
icon:"demoApp/icon_add.png",
click:function () {
itemList.selection.deselectAll();
itemDetailTabs.selectTab(1);
itemList.updateDetails();
}
},
{isSeparator:true},
{title:"Show Details",
icon:"demoApp/icon_view.png",
click:"itemDetailTabs.selectTab(0); itemList.updateDetails()"},
{title:"Edit Item",
icon:"demoApp/icon_edit.png",
click:"itemDetailTabs.selectTab(1); itemList.updateDetails()"},
{title:"Delete Item",
icon:"demoApp/icon_delete.png",
click:"itemList.removeSelectedData(); itemDetailTabs.clearDetails()"}
]
});
isc.DetailViewer.create({
ID:"itemViewer",
dataSource:supplyItem,
width:"100%",
margin:"25",
emptyMessage:"Select an item to view its details"
});
isc.DynamicForm.create({
ID:"editForm",
dataSource:supplyItem,
useAllDataSourceFields:true,
fields:[
{name:"SKU"},
{name:"description", editorType:"textArea",rowSpan:3, width:200},
{name:"category", editorType:"pickTree", dataSource:supplyCategory, // 无法显示editform
emptyMenuMessage:"No Sub Categories", canSelectParentItems:true},
{name:"unitCost", editorType:"spinner", step:0.01},
{name:"inStock"},
{name:"nextShipment", useTextField:true,editorType:"date"},
{name:"savebtn", editorType:"button", align:"center",
width:100, colSpan:4, title:"Save Item", click:"editForm.saveData()"}
],
width:650,
numCols:4,
colWidths:[100,200,100,200],
margin:25,
cellPadding:5,
autoFocus:false
});
isc.Label.create({
ID:"editorMessage",
autoDraw: false,
width:"100%",
height:"100%",
align:"center",
contents:"Select a record to edit, or a category to insert a new record into"
});
isc.TabSet.create({
ID:"itemDetailTabs",
tabs:[
{title:"View", pane:itemViewer, ID:"viewTab", width:70, icon:"demoApp/icon_view.png"},
{title:"Edit", pane:editForm, ID:"editTab", width:70, icon:"demoApp/icon_edit.png"}
],
tabSelected:"itemList.updateDetails()",
clearDetails : function () {
var selectedTab = this.getSelectedTabNumber();
if (selectedTab == 0) {
itemViewer.setData();
} else if (selectedTab == 1) {
if (categoryTree.getSelectedRecord() != null) {
this.updateTab("editTab", editForm);
editForm.editNewRecord({category:categoryTree.getSelectedRecord().categoryName});
} else {
this.updateTab("editTab", editorMessage);
}
}
}
});
// Define application layout
// ---------------------------------------------------------------------
isc.HLayout.create({
ID:"pageLayout",
width:"100%",
height:"100%",
layoutMargin:20,
members:[
isc.SectionStack.create({
ID:"leftSideLayout",
width:280,
showResizeBar:true,
visibilityMode:"multiple",
animateSections:true,
sections:[
{title:"Office Supply Categories", autoShow:true, items:[categoryTree]},
{title:"Instructions", autoShow:true, items:[helpCanvas]}
]
}),
isc.SectionStack.create({
ID:"rightSideLayout",
visibilityMode:"multiple",
animateSections:true,
sections:[
{title:"Find Items", autoShow:true, items:[
isc.Canvas.create({
ID:"findPane",
height:60,
overflow:"auto",
styleName:"defaultBorder",
children:[findForm,findButton]
})
]},
{title:"Office Supply Items", autoShow:true, items:[itemList]},
{title:"Item Details", autoShow:true, items:[itemDetailTabs]}
]
})
]
});
isc.Page.setEvent("load", "pageLayout.draw()");
// Custom logic:
// When showing options in the combo-box, only show the options from the selected category
// if appropriate
findForm.getItem("itemName").addProperties({
getPickListFilterCriteria : function () {
var criteria = this.Super("getPickListFilterCriteria", arguments);
if (this.form.getValue('findInCategory') && categoryTree.selection.anySelected()) {
criteria.category = categoryTree.getSelectedRecord().categoryName;
}
return criteria
}
});
categoryTree.fetchData();
java代碼
DAO 層
package isc.java.Dao;
import isc.java.Module.supplyItem;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class supplyItem_Dao {
private HibernateTemplate hibernateTemplate;
@SuppressWarnings("unused")
@Autowired
private void setHibernateTemplate (SessionFactory sessionFactory){
this.hibernateTemplate =new HibernateTemplate(sessionFactory);
}
/*
* function findAll
* 查询supplyItem表中所有记录
* 并以list形式返回
*
* */
@SuppressWarnings("unchecked")
public List<supplyItem> findAll(String category){
String hql="from supplyItem where category='"+category+"'";
List list=this.hibernateTemplate.find(hql);
return list;
}
/*
* 根据category返回对应的记录
* */
@SuppressWarnings("unchecked")
public supplyItem findInfoByID (int itemID){
supplyItem supp=(supplyItem) this.hibernateTemplate.get(supplyItem.class, itemID);
return supp;
}
/*
* 删除指定记录
*
* */
public void deleteInfo(supplyItem supp){
this.hibernateTemplate.delete(supp);
}
/*
* 更新修改后的记录
* */
public void updateInfo(supplyItem supp){
this.hibernateTemplate.update(supp);
}
/*
*增加记录
* */
public void insertInfo(supplyItem supp){
this.hibernateTemplate.save(supp);
}
}
package isc.java.Dao;
import isc.java.Module.supplyCategory;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class supplyCategory_Dao {
private HibernateTemplate hibernateTemplate;
@SuppressWarnings("unused")
@Autowired
private void setHibernateTemplate (SessionFactory sessionFactory){
this.hibernateTemplate =new HibernateTemplate(sessionFactory);
}
@SuppressWarnings("unchecked")
public List<supplyCategory> findAll(String parentId){
String hql="from supplyCategory where parentId='"+parentId+"'";
List list =this.hibernateTemplate.find(hql);
return list;
}
}
ENTITY層
package isc.java.Module;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="supplyCategory")
public class supplyCategory {
private String categoryName;
private String parentId;
@Id
@Column(name="categoryName")
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
@Column(name="parentId")
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
}
package isc.java.Module;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="supplyItem")
public class supplyItem {
private int itemID ;
private String itemName;
private double unitCost;
private String SKU;
private String description;
private String category;
private String inStock;
private String nextShipment;
@Id
@GeneratedValue
@Column(name="itemID")
public int getItemID() {
return itemID;
}
public void setItemID(int itemID) {
this.itemID = itemID;
}
@Column(name="itemName")
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
@Column(name="unitCost")
public double getUnitCost() {
return unitCost;
}
public void setUnitCost(double unitCost) {
this.unitCost= unitCost;
}
@Column(name="SKU")
public String getSKU() {
return SKU;
}
public void setSKU(String sku) {
SKU = sku;
}
@Column(name="description")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Column(name="category")
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
@Column(name="instock")
public String getInStock() {
return inStock;
}
public void setInStock(String inStock) {
this.inStock = inStock;
}
@Column(name="nextShipment")
public String getNextShipment() {
return nextShipment;
}
public void setNextShipment(String nextShipment) {
this.nextShipment = nextShipment;
}
}
Service 層
package isc.java.Service;
import isc.java.Dao.supplyCategory_Dao;
import isc.java.Module.supplyCategory;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class supplyCategory_Service {
private supplyCategory_Dao supplyCategory_dao;
@Autowired
public void setSupplyCategory_dao(supplyCategory_Dao supplyCategory_dao) {
this.supplyCategory_dao = supplyCategory_dao;
}
@Transactional("demoApp")
public List<supplyCategory> findAll(String parentId){
return this.supplyCategory_dao.findAll(parentId);
}
}
package isc.java.Service;
import isc.java.Dao.supplyItem_Dao;
import isc.java.Module.supplyItem;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class supplyItem_Service {
private supplyItem_Dao supplyItem_dao;
@Autowired
public void setSupplyItem_dao(supplyItem_Dao supplyItem_dao) {
this.supplyItem_dao = supplyItem_dao;
}
/*
* 使用声明式事物管理
* 在业务方法上进行@Transactional注解
* 将事物规则应用到业务逻辑中
* demoApp为限定词*_*
* */
@Transactional("demoApp")
public List<supplyItem> findAll(String category){
return this.supplyItem_dao.findAll(category);
}
@Transactional("demoApp")
public supplyItem findInfoByID(int itemID){
return this.supplyItem_dao.findInfoByID(itemID);
}
@Transactional("demoApp")
public void deleteInfo(int itemID){
supplyItem supp =this.supplyItem_dao.findInfoByID(itemID);
this.supplyItem_dao.deleteInfo(supp);
}
@Transactional("demoApp")
public void updateInfo(supplyItem supp){
this.supplyItem_dao.updateInfo(supp);
}
@Transactional("demoApp")
public void insertInfo(supplyItem supp){
this.supplyItem_dao.insertInfo(supp);
}
}
Web層
package isc.java.Web;
import isc.java.Module.supplyCategory;
import isc.java.Service.supplyCategory_Service;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class supplyCategory_Controller {
private supplyCategory_Service supplyCategory_service;
@Autowired
public void setSupplyCategory_service(
supplyCategory_Service supplyCategory_service) {
this.supplyCategory_service = supplyCategory_service;
}
@SuppressWarnings("unchecked")
@RequestMapping(value="demoApp/findTreeAll.action")
public void findAll(HttpServletResponse response,HttpServletRequest request){
String parentId=request.getParameter("parentID");
List<supplyCategory> list=this.supplyCategory_service.findAll(parentId);
ServletOutputStream sos=null;
try {
sos=response.getOutputStream();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
StringBuffer sbu=new StringBuffer();
Iterator ita=(Iterator)list.iterator();
while(ita.hasNext()){
supplyCategory supplycategory=(supplyCategory)ita.next();
sbu.append("<country>");
sbu.append("<categoryName>"+supplycategory.getCategoryName()+"</categoryName>");
sbu.append("<parentId>"+supplycategory.getParentId()+"</parentId>");
sbu.append("</country>");
}
try {
sos.print("<?xml version='1.0' encoding='UTF-8'?><records>"+sbu.toString()+"</records>");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
package isc.java.Web;
import isc.java.Module.supplyItem;
import isc.java.Service.supplyItem_Service;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class supplyItem_Controller {
private supplyItem_Service supplyItem_service;
@Autowired
public void setSupplyItem_service(supplyItem_Service supplyItem_service) {
this.supplyItem_service = supplyItem_service;
}
/*
* 从数据库中提取数据 以xml格式存储
*
* */
@SuppressWarnings("unchecked")
@RequestMapping(value="demoApp/findAll.action")
public void findAll(HttpServletResponse response,HttpServletRequest request){
String category=request.getParameter("category");//接受前台传过来的参数
List<supplyItem>list =this.supplyItem_service.findAll(category);
ServletOutputStream sos=null;
try {
sos = response.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
StringBuffer sbu=new StringBuffer();
Iterator ita = (Iterator) list.iterator();
while(ita.hasNext()){
supplyItem supplyitem=(supplyItem)ita.next();
sbu.append("<country>");
sbu.append("<itemID>"+supplyitem.getItemID()+"</itemID>");
sbu.append("<itemName>"+supplyitem.getItemName()+"</itemName>");
sbu.append("<unitCost>"+supplyitem.getUnitCost()+"</unitCost>");
sbu.append("<SKU>"+supplyitem.getSKU()+"</SKU>");
sbu.append("<description>"+supplyitem.getDescription()+"</description>");
sbu.append("<category>"+supplyitem.getCategory()+"</category>");
sbu.append("<inStock>"+supplyitem.getInStock()+"</inStock>");
sbu.append("<nextShipment>"+supplyitem.getNextShipment()+"</nextShipment>");
sbu.append("</country>");
}
try {
sos.print("<?xml version='1.0' encoding='UTF-8'?><records>"+sbu.toString()+"</records>");
} catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping(value="demoApp/deleteInfo.action")
public void deleteInfo(HttpServletRequest request){
int itemID=Integer.parseInt(request.getParameter("itemID"));
System.out.println("test======================"+itemID);
this.supplyItem_service.deleteInfo(itemID);
}
@RequestMapping(value="demoApp/updateInfo.action")
public void updateInfo(HttpServletRequest request){
int itemID=Integer.parseInt(request.getParameter("itemID"));
supplyItem supp=this.supplyItem_service.findInfoByID(itemID);
supp.setSKU(request.getParameter("SKU"));
supp.setCategory(request.getParameter("category"));
supp.setDescription(request.getParameter("description"));
supp.setInStock(request.getParameter("inStock"));
supp.setItemName(request.getParameter("itemName"));
supp.setNextShipment(request.getParameter("nextShipment"));
String s=request.getParameter("unitCost");
supp.setUnitCost(Double.parseDouble(s));
this.supplyItem_service.updateInfo(supp);
}
@RequestMapping(value="demoApp/insertInfo.action")
public void insertInfo(HttpServletRequest request){
supplyItem supp=new supplyItem();
supp.setCategory(request.getParameter("category"));
supp.setSKU(request.getParameter("SKU"));
supp.setDescription(request.getParameter("description"));
supp.setInStock(request.getParameter("inStock"));
supp.setItemName(request.getParameter("itemName"));
supp.setNextShipment(request.getParameter("nextShipment"));
supp.setUnitCost(Double.parseDouble(request.getParameter("unitCost")));
this.supplyItem_service.insertInfo(supp);
}
}
Xml
App-config.xml
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- Scans the classpath of this application for @Components to deploy as beans -->
<!-- 規約所有進行掃描的類,以完成Bean創建和自動依賴注入功能 -->
<context:component-scan base-package="isc.java.*" />
<!-- <context:annotation-config /> -->
<!-- Configures the @Controller programming model -->
<mvc:annotation-driven />
<!-- misc -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="suffix" value=".action"/>
</bean>
<!-- Configures Hibernate - Database Config -->
<import resource="db-config.xml" />
</beans>
Db-config.xml
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value></property>
<property name="url"><value>jdbc:sqlserver://10.1.100.215:1433;DatabaseName=email</value></property>
<property name="username"><value>dev</value></property>
<property name="password"><value>12345678aA</value></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="packagesToScan" value="isc.java.*" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- <prop key="hibernate.hbm2ddl.auto">update</prop>-->
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<tx:annotation-driven/>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
<qualifier value="demoApp"/> <!-- 限定词 -->
</bean>
</beans>