81,094
社区成员
发帖
与我相关
我的任务
分享
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml,/WEB-INF/common.xml,/WEB-INF/basic-spring.xml,/WEB-INF/system-spring.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver">
</property>
<property name="url"
value="jdbc:microsoft:sqlserver://localhost;databasename=sdwms">
</property>
<property name="username" value="sa"></property>
<property name="password" value=""></property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="baseTransaction" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager" ref="transactionManager"/>
<property name="proxyTargetClass" value="true"/>
<property name="transactionAttributes">
<props>
<prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="count*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="execute**">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="search*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="preAdd*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="listDel*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean name="commonDao" class="com.szdzsoft.dao.impl.CommonDaoImple">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 货品单位 -->
<bean name="produnitService" parent="baseTransaction">
<property name="target">
<ref bean="produnitServiceTarget" />
</property>
</bean>
<bean id="produnitServiceTarget"
class="com.xxx.service.impl.basic.ProdunitServiceImpl"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
<property name="commonDao">
<ref bean="commonDao" />
</property>
</bean>
<bean name="/produnit" class="com.xxx.web.action.basic.ProdunitAction">
<property name="customerService">
<ref bean="customerService"/>
</property>
<property name="produnitService">
<ref bean="produnitService"/>
</property>
</bean>
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
request.setAttribute("units",this.unitService.listBsProdunitAll());
request.setAttribute("units",this.unitService.listBsProdunitAll());
request.setAttribute("units",this.unitService.listBsProdunitAll());
request.setAttribute("units",this.unitService.listBsProdunitAll());
request.setAttribute("units",this.unitService.listBsProdunitAll());
request.setAttribute("units",this.unitService.listBsProdunitAll());
request.setAttribute("units",this.unitService.listBsProdunitAll());
request.setAttribute("units",this.unitService.listBsProdunitAll());
request.setAttribute("units",this.unitService.listBsProdunitAll());
request.setAttribute("units",this.unitService.listBsProdunitAll());
return mapping.findForward("update");
}
public List listBsProdunitAll(){
return commonDao.executeQuery("from BsProdunit o order by id");
}
public List executeQuery(final String hql, final Object[] param, final int start, final int pageSize)
{
return (List)getHibernateTemplate().execute(new HibernateCallback()//这里使用了匿名内部类
{
public Object doInHibernate(Session session)//Spring进行事务维护 省去每次创建session和关闭session
throws HibernateException
{
// TODO Auto-generated method stub
List list = new ArrayList();
if(hql==null || hql.equals(""))
{
return list;
}
//System.out.println(hql);
Query query = session.createQuery(hql);
if(hql.indexOf("?")>0 && param!=null && param.length>0)
{
//System.out.println(hql+"++++++++++++++++++"+param[0]);
//query.setParameter(0,"aaa" );
//query.setp
for(int i=0;i<param.length;i++)
{
query.setParameter(i, param[i]);
}
}else if(hql.indexOf(" ?")<0 && param!=null)
{
return list;
}
if(start>=0 && pageSize>0)
{
query.setFirstResult(start);
query.setMaxResults(pageSize);
}
list = query.list();
session.clear();
return list;
}
}, true);
}
public List executeQuery(String hql, Object[] param) {
// TODO Auto-generated method stub
return this.executeQuery(hql, param, -1,-1);
}
public List executeQuery(String hql) {
// TODO Auto-generated method stub
return this.executeQuery(hql, null);
}
<property name="maxActive">
<value>0</value>
</property>
<property name="maxIdle">
<value>30</value>
</property>
<property name="maxWait">
<value>10000</value>
</property>