??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲黄色一级毛片,亚洲av无码乱码国产精品fc2,中文字幕乱码亚洲精品一区http://m.tkk7.com/zhanglijun33/category/17946.htmlhQ彷徨,立志Q蓄?..zh-cnFri, 02 Mar 2007 03:10:01 GMTFri, 02 Mar 2007 03:10:01 GMT60spring 实践Q进一步理解和使用aophttp://m.tkk7.com/zhanglijun33/archive/2006/07/27/aoptest.html无?/dc:creator>无?/author>Thu, 27 Jul 2006 09:04:00 GMThttp://m.tkk7.com/zhanglijun33/archive/2006/07/27/aoptest.htmlhttp://m.tkk7.com/zhanglijun33/comments/60383.htmlhttp://m.tkk7.com/zhanglijun33/archive/2006/07/27/aoptest.html#Feedback18http://m.tkk7.com/zhanglijun33/comments/commentRss/60383.htmlhttp://m.tkk7.com/zhanglijun33/services/trackbacks/60383.htmlaop是面向切面编E的Q由此首先应该弄清的是:(x)什么是切面Q?br />切面是切入点和通知的结合体?br />怎样l织一个切面?换句话说怎么把众多的cȝl成一个切面?p看我们在哪些cȝ代理cM插入相同的通知?jin)。过多的例子不再举了(jin)Q如果谁惌一份testAOP工程实例Q可以给我留a?br />本程序说明:(x)
tom是公司的一位经理managerQpojoQ?br />׃事务J忙Q他聘用?jin)一个秘?sh)secretaryQ通知Q,
每当l理上班的时候,U(sh)M(x)把一天的计划自动的提前交l经理ƈ作口水状?br />而对于别人,她的态度׃是那么好?jin)?br />在这个程序中Q我们的U(sh)对经理说话的时候用的是前置通知?br />Ҏ(gu)通工话的时候用的是后置通知?br />点一下运行看看程序的l果吧?

]]>
SpringFramework中的AOP单? http://m.tkk7.com/zhanglijun33/archive/2006/07/25/aop.html无?/dc:creator>无?/author>Tue, 25 Jul 2006 03:38:00 GMThttp://m.tkk7.com/zhanglijun33/archive/2006/07/25/aop.htmlhttp://m.tkk7.com/zhanglijun33/comments/59957.htmlhttp://m.tkk7.com/zhanglijun33/archive/2006/07/25/aop.html#Feedback1http://m.tkk7.com/zhanglijun33/comments/commentRss/59957.htmlhttp://m.tkk7.com/zhanglijun33/services/trackbacks/59957.html
SpringFramework中的AOP单?
AOP作ؓ(f)Springq个轻量U的容器中很重要的一部分Q得到越来越多的x(chng)QSpring的Transaction是用AOP来管理的Q今天就通过单的例子来看看Spring中的AOP的基本用方法?

 (tng) 首先定要Proxy的目标,在Spring中默认采用JDK中的dynamic proxyQ它只能够实现接口的代理Q如果想对类q行代理的话Q需要采用CGLIB的proxy。显?dng)选择“编E到接口”是更明智的做法Q下面是要代理的接口:(x)

 (tng) public interface FooInterface {
 (tng) (tng) (tng) public void printFoo();
 (tng) (tng) (tng) public void dummyFoo();
 (tng) }

 (tng)
 (tng) 以及(qing)其一个简单的实现Q?br /> (tng)
 (tng) public class FooImpl implements FooInterface {
 (tng) (tng) (tng) public void printFoo() {
 (tng) (tng) (tng) (tng) (tng) System.out.println("In FooImpl.printFoo");
 (tng) (tng) (tng) }
 (tng) (tng) (tng) public void dummyFoo() {
 (tng) (tng) (tng) (tng) (tng) System.out.println("In FooImpl.dummyFoo");
 (tng) (tng) (tng) }
 (tng) }

 (tng)
 (tng) 接下来创Z个AdviceQ在Spring中支持Around,Before,After returning和Throws四种AdviceQ这里就以简单的Before Advice举例Q?br /> (tng)
 (tng) public class PrintBeforeAdvice implements MethodBeforeAdvice {
 (tng) (tng) (tng) public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable {
 (tng) (tng) (tng) (tng) (tng) System.out.println("In PrintBeforeAdvice");
 (tng) (tng) (tng) }
 (tng) }
 (tng)
 (tng) 有了(jin)自己的business interface和adviceQ剩下的是如何去装配它们了(jin)Q首先利用ProxyFactory以编E方式实玎ͼ如下Q?br /> (tng)
 (tng) public class AopTestMain {
 (tng) (tng) (tng) public static void main(String[] args) {
 (tng) (tng) (tng) (tng) (tng) FooImpl fooImpl = new FooImpl();
 (tng) (tng) (tng) (tng) (tng) PrintBeforeAdvice myAdvice = new PrintBeforeAdvice();
 (tng) (tng) (tng) (tng) (tng)
 (tng) (tng) (tng) (tng) (tng) ProxyFactory factory = new ProxyFactory(fooImpl);
 (tng) (tng) (tng) (tng) (tng) factory.addBeforeAdvice(myAdvice);
 (tng) (tng) (tng) (tng) (tng) FooInterface myInterface = (FooInterface)factory.getProxy();

 (tng) (tng) (tng) (tng) (tng) myInterface.printFoo();
 (tng) (tng) (tng) (tng) (tng) myInterface.dummyFoo();
 (tng) (tng) (tng) }
 (tng) }
 (tng)
 (tng) 现在执行E序Q神奇的l果出C(jin)Q?br /> (tng)
 (tng) In PrintBeforeAdvice
 (tng) In FooImpl.printFoo
 (tng) In PrintBeforeAdvice
 (tng) In FooImpl.dummyFoo

 (tng)
 (tng) 虽然q样能体?x)到Spring中AOP的用法,但这决不是值得推荐的方法,既然使用?jin)SpringQ在ApplicationContext中装配所需?的bean才是最佳策略,实现上面的功能只需要写个简单的applicationContext可以了(jin)Q如下:(x)
 (tng)
 (tng) <?xml version="1.0" encoding="UTF-8"?>
 (tng) <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
 (tng) (tng) (tng) "
http://www.springframework.org/dtd/spring-beans.dtd">

 (tng) <beans>
 (tng) (tng) (tng) <description>The aop application context</description>
 (tng) (tng) (tng) <bean id="fooTarget" class="FooImpl"/>
 (tng) (tng) (tng) <bean id="myAdvice" class="PrintBeforeAdvice"/>
 (tng) (tng)  (tng)<bean id="foo" class="org.springframework.aop.framework.ProxyFactoryBean">
 (tng) (tng) (tng) (tng) <property name="proxyInterfaces">
 (tng) (tng) (tng) (tng) (tng) (tng) <value>FooInterface</value>
 (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng)<property name="target">
 (tng) (tng) (tng) (tng) (tng) (tng) <ref local="fooTarget"/>
 (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) <property name="interceptorNames">
 (tng) (tng) (tng) (tng) (tng) (tng) <list>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>myAdvice</value>
 (tng) (tng) (tng) (tng) (tng) (tng) </list>
 (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) </bean>
 (tng) </beans>

 (tng) 当然Qmain中的代码也要q行相应的修改:(x)
 (tng) (tng) (tng) (tng)
 (tng) public static void main(String[] args) {
 (tng) (tng) (tng) ClassPathXmlApplicationContext context = new (tng)
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)ClassPathXmlApplicationContext("applicationContext.xml");
 (tng) (tng) (tng) FooInterface foo = (FooInterface)context.getBean("foo");
 (tng) (tng) (tng) foo.printFoo();
 (tng) (tng) (tng) foo.dummyFoo();
 (tng) }

 (tng)
 (tng) 现在q行一下,l果和上面的运行结果完全一Pq样是不是更优雅Q当需要更改实现时Q只需要修攚w|文件就可以?jin),E序中的代码不需M改动?br /> (tng)
 (tng) 但是Q这时候会(x)发现被proxy的object中的所有方法调用时都将q行advice中的beforeQ这昄不能满l大多数情况下的需要,此时Q只 需借用Advisor可以了(jin)Q当然要在Advisor中利用pattern讄好哪些方法需要adviceQ更改applicationContext 如下Q?br /> (tng)
 (tng) <?xml version="1.0" encoding="UTF-8"?>
 (tng) <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
 (tng) (tng) (tng) "
http://www.springframework.org/dtd/spring-beans.dtd">

 (tng) <beans>
 (tng) (tng) (tng) <description>The springeva application context</description>
 (tng) (tng)  (tng)<bean id="fooTarget" class="FooImpl"/>
 (tng) (tng) (tng) <bean id="printBeforeAdvice" class="PrintBeforeAdvice"/>
 (tng) (tng) (tng) <bean id="myAdvisor"
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
 (tng) (tng) (tng) (tng) (tng) <property name="advice">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref local="printBeforeAdvice"/>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) <property name="pattern">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>.*print.*</value>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) </bean>
 (tng) (tng) (tng) <bean id="foo" class="org.springframework.aop.framework.ProxyFactoryBean">
 (tng) (tng) (tng) (tng) (tng) <property name="proxyInterfaces">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)<value>FooInterface</value>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) <property name="target">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref local="fooTarget"/>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) <property name="interceptorNames">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <list>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>myAdvisor</value>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) </list>
 (tng) (tng) (tng) (tng) (tng) (tng)</property>
 (tng) (tng) (tng) </bean>
 (tng) </beans>

 (tng) ȝ序不需q行M修改Q运行结果已l变样了(jin)Q?/p>

 (tng) In PrintBeforeAdvice
 (tng) In FooImpl.printFoo
 (tng) In FooImpl.dummyFoo

 (tng)
 (tng) x(chng)Q应该已l理解了(jin)Spring中AOP的用方法,当然Spring中AOP最重要的应用是Transaction ManagerQD个这斚w的applicationContext例子看看Q?br /> (tng)
 (tng) <?xml version="1.0" encoding="UTF-8"?>
 (tng) <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "spring-beans.dtd">

 (tng) <beans>
 (tng) (tng) (tng) <bean id="propertyConfigurer" (tng) (tng) (tng)
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
 (tng) (tng) (tng) (tng) (tng) <property name="location">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>/WEB-INF/jdbc.properties</value>
 (tng) (tng) (tng) (tng) (tng) (tng)</property>
 (tng) (tng)  (tng)</bean>
 (tng) (tng) (tng) <bean id="dataSource"
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) class="org.springframework.jdbc.datasource.DriverManagerDataSource">
 (tng) (tng) (tng) (tng) (tng) <property name="driverClassName">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>${jdbc.driverClassName}</value>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) (tng)<property name="url">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>${jdbc.url}</value>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) <property name="username">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>${jdbc.username}</value>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) <property name="password">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>${jdbc.password}</value>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) </bean>
 (tng) (tng)  (tng)<bean id="sessionFactory"
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
 (tng) (tng) (tng) (tng) (tng) <property name="dataSource">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref local="dataSource"/>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) <property name="mappingResources">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>smartmenu.hbm.xml</value>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) <property name="hibernateProperties">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <props>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <prop key="hibernate.dialect">${hibernate.dialect}</prop>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) </props>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) </bean>
 (tng)
 (tng) (tng) (tng) <bean id="transactionManager" (tng) (tng) (tng) (tng) (tng) (tng) (tng)
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) class="org.springframework.orm.hibernate.HibernateTransactionManager">
 (tng) (tng) (tng) (tng) (tng) <property name="sessionFactory">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref local="sessionFactory"/>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) </bean>
 (tng) (tng) (tng) <bean id="smartmenuTarget" class="SmartMenuHibernate">
 (tng) (tng) (tng) (tng) (tng) <property name="sessionFactory">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref local="sessionFactory"/>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) </bean>
 (tng) (tng)  (tng)<bean id="smartMenu"
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
 (tng) (tng) (tng) (tng) (tng) <property name="transactionManager">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref local="transactionManager"/>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) <property name="target">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref local="smartmenuTarget"/>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) <property name="transactionAttributes">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <props>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) </props>
 (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) </bean>
 (tng) </beans>

 (tng)
 (tng) 要想d理解Spring的AOPQ最好还是多看看源码Q开源就是好啊!



]]>
Hibernate+Spring 对DAO的处理实?http://m.tkk7.com/zhanglijun33/archive/2006/07/25/goodacticle.html无?/dc:creator>无?/author>Tue, 25 Jul 2006 03:23:00 GMThttp://m.tkk7.com/zhanglijun33/archive/2006/07/25/goodacticle.htmlhttp://m.tkk7.com/zhanglijun33/comments/59954.htmlhttp://m.tkk7.com/zhanglijun33/archive/2006/07/25/goodacticle.html#Feedback0http://m.tkk7.com/zhanglijun33/comments/commentRss/59954.htmlhttp://m.tkk7.com/zhanglijun33/services/trackbacks/59954.html
 (tng)
引用"Spring"手册上的话说: Hibernate+Spring昄是天生的l合.

下面是我用spring处理的一个HibernateDAO实例,可以看到,代码量大大减了(jin).

java代码: (tng)


package infoweb.dao;

import java.util.List;
import java.util.Iterator;

import infoweb.pojo.Info;


import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;
import net.sf.hibernate.Session;

import org.springframework.orm.hibernate.HibernateCallback;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;


/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author D|?br />* @version 1.0
*/


publicclass InfoDAOImpl extends HibernateDaoSupport implements IInfoDAO {
 (tng) /**
 (tng)  (tng)* 构造函?br /> (tng)  (tng)*/

 (tng) public InfoDAOImpl(){
 (tng) (tng) (tng) super();
 (tng) }


 (tng) /**
 (tng)  (tng)* 增加记录
 (tng)  (tng)* @param info Info
 (tng)  (tng)*/

 (tng) publicvoid setInfo(Info info)throwsException{
 (tng) (tng) (tng) getHibernateTemplate().save(info);
 (tng) }


 (tng) /**
 (tng)  (tng)* 通过ID取得记录
 (tng)  (tng)* @param id String
 (tng)  (tng)* @return Info
 (tng)  (tng)*/

 (tng) public Info getInfoById(String id)throwsException{
 (tng) (tng) (tng) Info info = (Info) getHibernateTemplate().load(Info.class, id);
 (tng) (tng) (tng) return info;
 (tng) }


 (tng) /**
 (tng)  (tng)* 修改记录
 (tng)  (tng)* @param Info info
 (tng)  (tng)*/

 (tng) publicvoid modifyInfo(Info info)throwsException{
 (tng) (tng) (tng) getHibernateTemplate().update(info);
 (tng) }


 (tng) /**
 (tng)  (tng)* 删除记录
 (tng)  (tng)* @param Info info
 (tng)  (tng)*/

 (tng) publicvoid removeInfo(Info info)throwsException{
 (tng) (tng) (tng) getHibernateTemplate().delete(info);
 (tng) }


 (tng) ////////////////////////////////////////////////////////
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) /////以下部䆾不带审核功能 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ////////////////////////////////////////////////////////

 (tng) /**
 (tng)  (tng)* 取记录L
 (tng)  (tng)* @return int
 (tng)  (tng)*/

 (tng) publicint getInfosCount()throwsException{
 (tng) (tng) (tng) int count = 0;
 (tng) (tng) (tng) String queryString = "select count(*) from Info";
 (tng) (tng) (tng) count = ((Integer) getHibernateTemplate().iterate(queryString).next()).
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) intValue();
 (tng) (tng) (tng) return count;
 (tng) }


 (tng) /**
 (tng)  (tng)* 取所有记录集?br /> (tng)  (tng)* @return Iterator
 (tng)  (tng)*/

 (tng) publicIterator getAllInfos()throwsException{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString = " select info from Info as info order by info.id desc";
 (tng) (tng) (tng) List list = getHibernateTemplate().find(queryString);
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) return iterator;
 (tng) }


 (tng) /**
 (tng)  (tng)* 取记录集?br /> (tng)  (tng)* @return Iterator
 (tng)  (tng)* @param int position, int length
 (tng)  (tng)*/

 (tng) publicIterator getInfos(int position, int length)throwsException{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString = " select info from Info as info order by info.id desc";
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //讄游标的v始点
 (tng) (tng) (tng) query.setFirstResult(position);
 (tng) (tng) (tng) //讄游标的长?/span>
 (tng) (tng) (tng) query.setMaxResults(length);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) return iterator;
 (tng) }


 (tng) /**
 (tng)  (tng)* 取第一条记?br /> (tng)  (tng)* @throws Exception
 (tng)  (tng)* @return Station
 (tng)  (tng)*/

 (tng) public Info getFirstInfo()throwsException{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) Info info = null;
 (tng) (tng) (tng) String queryString = "select info from Info as info order by info.id desc";
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) if(iterator.hasNext()){
 (tng) (tng) (tng) (tng) (tng) info = (Info) iterator.next();
 (tng) (tng) (tng) }
 (tng) (tng) (tng) return info;
 (tng) }


 (tng) /**
 (tng)  (tng)* 取最后一条记?br /> (tng)  (tng)* @throws Exception
 (tng)  (tng)* @return Station
 (tng)  (tng)*/

 (tng) public Info getLastInfo()throwsException{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) Info info = null;
 (tng) (tng) (tng) String queryString = "select info from Info as info order by info.id asc";
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) if(iterator.hasNext()){
 (tng) (tng) (tng) (tng) (tng) info = (Info) iterator.next();
 (tng) (tng) (tng) }
 (tng) (tng) (tng) return info;

 (tng) }


 (tng) ////////////////////////////////////////////////////////
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ///// 以下部䆾表中要有特定字段才能Õ(li)吩诵袪 牳鋈撕推W禒  (tng)  (tng)///
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ////////////////////////////////////////////////////////

 (tng) /**
 (tng)  (tng)* 取符合条件记录L, [表中要有 isperson 字段]
 (tng)  (tng)* @return int
 (tng)  (tng)* @param int isPerson
 (tng)  (tng)*/


 (tng) publicint getInfosCountByIsperson(int isPerson)throwsException{
 (tng) (tng) (tng) int count = 0;
 (tng) (tng) (tng) String queryString =
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) "select count(*) from Info as info where info.isperson =" + isPerson;
 (tng) (tng) (tng) count = ((Integer) getHibernateTemplate().iterate(queryString).next()).
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) intValue();
 (tng) (tng) (tng) return count;
 (tng) }


 (tng) /**
 (tng)  (tng)* 取所有符合条件记录集? 模糊查询条g.[表中要有 isperson 字段]
 (tng)  (tng)* @return Iterator
 (tng)  (tng)* @param int isPerson
 (tng)  (tng)*/


 (tng) publicIterator getAllInfosByIsperson(int isPerson)throwsException{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString = " select info from Info as info where info.isperson =" +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)  (tng)isPerson + " order by info.id desc";
 (tng) (tng) (tng) List list = getHibernateTemplate().find(queryString);
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) return iterator;
 (tng) }


 (tng) /**
 (tng)  (tng)* 取符合条件记录集? 模糊查询条g.[表中要有 isperson 字段]
 (tng)  (tng)* @return Iterator
 (tng)  (tng)* @param int isPerson,int position, int length
 (tng)  (tng)*/


 (tng) publicIterator getInfosByIsperson(int isPerson, int position, int length)throws
 (tng) (tng) (tng) (tng) (tng) Exception{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString = " select info from Info as info where info.isperson =" +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)  (tng)isPerson + " order by info.id desc";
 (tng) (tng) (tng) //创徏查询
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //讄游标的v始点
 (tng) (tng) (tng) query.setFirstResult(position);
 (tng) (tng) (tng) //讄游标的长?/span>
 (tng) (tng) (tng) query.setMaxResults(length);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) return iterator;
 (tng) }


 (tng) ////////////////////////////////////////////////////////
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ///// 以下部䆾表中要有特定字段才能Õ(li)吩诵袪  (tng)查询部䆾 (tng) (tng) (tng) (tng) (tng) ///
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ///////////////////////////////////////////////////////
 (tng) /**
 (tng)  (tng)* 取符合条件记录L, 模糊查询条g.[表中要有 title 字段]
 (tng)  (tng)* @return int
 (tng)  (tng)* @param String text
 (tng)  (tng)*/

 (tng) publicint getInfosCount(String text)throwsException{
 (tng) (tng) (tng) int count = 0;
 (tng) (tng) (tng) count = ((Integer) getHibernateTemplate().iterate(
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) "select count(*) from Info as info where info.title like '%" + text +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) "%'
").next()).intValue();
 (tng) (tng) (tng) return count;
 (tng) }


 (tng) /**
 (tng)  (tng)* 取所有符合条件记录集? 模糊查询条g.[表中要有 title 字段]
 (tng)  (tng)* @return Iterator
 (tng)  (tng)* @param String text
 (tng)  (tng)*/


 (tng) publicIterator getAllInfos(String text)throwsException{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString =
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) " select info from Info as info where info.title like '%" + text +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) "%'
order by info.id desc";
 (tng) (tng) (tng) //创徏查询
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) return iterator;
 (tng) }


 (tng) /**
 (tng)  (tng)* 取符合条件记录集? 模糊查询条g.[表中要有 title 字段]
 (tng)  (tng)* @return Iterator
 (tng)  (tng)* @param String text,int position, int length
 (tng)  (tng)*/

 (tng) publicIterator getInfos(String text, int position, int length)throws
 (tng) (tng) (tng) (tng) (tng) Exception{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString =
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) " select info from Info as info where info.title like '%" + text +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) "%'
order by info.id desc";

 (tng) (tng) (tng) //创徏查询
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //讄游标的v始点
 (tng) (tng) (tng) query.setFirstResult(position);
 (tng) (tng) (tng) //讄游标的长?/span>
 (tng) (tng) (tng) query.setMaxResults(length);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) return iterator;
 (tng) }


 (tng) ////////////////////////////////////////////////////////
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ///// 以下部䆾表中要有特定字段才能Õ(li)吩诵袪 犠⒉嵯喙? (tng) (tng) (tng) ///
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ////////////////////////////////////////////////////////

 (tng) /**
 (tng)  (tng)* 取符合条件记录L.[ 表中要有 registername 字段]
 (tng)  (tng)* @return int
 (tng)  (tng)* @param String text
 (tng)  (tng)*/

 (tng) publicint getInfosCountByRegisterName(String registerName)throwsException{
 (tng) (tng) (tng) int count = 0;
 (tng) (tng) (tng) count = ((Integer) getHibernateTemplate().iterate(
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) "select count(*) from Info as info where info.registername = '" +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) registerName + "'
").next()).intValue();
 (tng) (tng) (tng) return count;
 (tng) }


 (tng) /**
 (tng)  (tng)* 通过注册名取得一条记?如有多条,只取W一?[表中要有 registername字段]
 (tng)  (tng)* @param registername String
 (tng)  (tng)* @return Info
 (tng)  (tng)*/

 (tng) public Info getInfoByRegisterName(String registerName)throwsException{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) Info info = null;
 (tng) (tng) (tng) String queryString =
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) " select info from Info as info where info.registername='" +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) registerName + "'
order by info.id desc";
 (tng) (tng) (tng) //创徏查询
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) if(iterator.hasNext()){
 (tng) (tng) (tng) (tng) (tng) info = (Info) iterator.next();
 (tng) (tng) (tng) }
 (tng) (tng) (tng) return info;
 (tng) }


 (tng) /**
 (tng)  (tng)* 通过注册名取得所有记录集?[表中要有 registername字段]
 (tng)  (tng)* @param registername String
 (tng)  (tng)* @return Iterator
 (tng)  (tng)*/

 (tng) publicIterator getAllInfosByRegisterName(String registerName)throws
 (tng) (tng) (tng) (tng) (tng) Exception{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString =
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) " select info from Info as info where info.registername='" +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) registerName + "'
order by info.id desc";
 (tng) (tng) (tng) //创徏查询
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) return iterator;
 (tng) }


 (tng) /**
 (tng)  (tng)* 通过注册名取得记录列?[表中要有 registername字段]
 (tng)  (tng)* @param registername String
 (tng)  (tng)* @return Iterator
 (tng)  (tng)*/

 (tng) publicIterator getInfosByRegisterName(String registerName, int position,
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)  (tng)int length)throwsException{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString =
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) " select info from Info as info where info.registername='" +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) registerName + "'
order by info.id desc";
 (tng) (tng) (tng) //创徏查询
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //讄游标的v始点
 (tng) (tng) (tng) query.setFirstResult(position);
 (tng) (tng) (tng) //讄游标的长?/span>
 (tng) (tng) (tng) query.setMaxResults(length);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) return iterator;
 (tng) }


 (tng) ////////////////////////////////////////////////////////
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ///// 以下部䆾表中要有特定字段才能Õ(li)吩诵袪  (tng) 犑餍桶婵? (tng)  (tng)///
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ////////////////////////////////////////////////////////

 (tng) /**
 (tng)  (tng)* 取记录L.[ 表中要有 board_id 字段]
 (tng)  (tng)* @return int
 (tng)  (tng)* @param String boardId
 (tng)  (tng)*/

 (tng) publicint getInfosCountByBoard(String boardId)throwsException{
 (tng) (tng) (tng) int count = 0;

 (tng) (tng) (tng) count = ((Integer) getHibernateTemplate().iterate(
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) "select count(*) from Info as info where info.boardId = '" + boardId +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) "'
").next()).intValue();

 (tng) (tng) (tng) return count;
 (tng) }


 (tng) /**
 (tng)  (tng)* 通过版块名取得所有记录集?[表中要有 board_id字段]
 (tng)  (tng)* @param BoardId String
 (tng)  (tng)* @return Iterator
 (tng)  (tng)*/

 (tng) publicIterator getAllInfosByBoard(String boardId)throwsException{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString = " select info from Info as info where info.boardId='" +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)  (tng)boardId + "'
order by info.id desc";
 (tng) (tng) (tng) //创徏查询
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) return iterator;
 (tng) }


 (tng) /**
 (tng)  (tng)* 通过版块名取得记录列?[表中要有 board_id字段]
 (tng)  (tng)* @param BoardId String
 (tng)  (tng)* @return Iterator
 (tng)  (tng)*/

 (tng) publicIterator getInfosByBoard(String boardId, int position, int length)throws
 (tng) (tng) (tng) (tng) (tng) Exception{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString = " select info from Info as info where info.boardId='" +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)  (tng)boardId + "'
order by info.id desc";

 (tng) (tng) (tng) //创徏查询
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //讄游标的v始点
 (tng) (tng) (tng) query.setFirstResult(position);
 (tng) (tng) (tng) //讄游标的长?/span>
 (tng) (tng) (tng) query.setMaxResults(length);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();

 (tng) (tng) (tng) return iterator;

 (tng) }


 (tng) /**
 (tng)  (tng)* 取符合条件记录L.[ 表中要有 board_id 字段,title] (tng) 模糊查询title
 (tng)  (tng)* @return int
 (tng)  (tng)* @param String boardId ,String text
 (tng)  (tng)*/

 (tng) publicint getInfosCountByBoard(String boardId, String text)throwsException{
 (tng) (tng) (tng) int count = 0;

 (tng) (tng) (tng) count = ((Integer) getHibernateTemplate().iterate(
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) "select count(*) from Info as info where info.boardId='" + boardId +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) "'
and info.title like '%" + text + "%'").next()).intValue();

 (tng) (tng) (tng) return count;

 (tng) }


 (tng) /**
 (tng)  (tng)* 通过版块名取得记录列?[表中要有 board_id字段] (tng) 模糊查询title
 (tng)  (tng)* @param String boardID,int position, int length
 (tng)  (tng)* @return Iterator
 (tng)  (tng)*/

 (tng) publicIterator getInfosByBoard(String boardId, int position, int length,
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) String text)throwsException{
 (tng) (tng) (tng) Iterator iterator = null;
 (tng) (tng) (tng) String queryString = " select info from Info as info where info.boardId='" +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)  (tng)boardId + "'
and info.title like '%" + text +
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng)  (tng)"%'
order by info.id desc";

 (tng) (tng) (tng) //创徏查询
 (tng) (tng) (tng) Query query = getHibernateTemplate().createQuery(getSession(), queryString);
 (tng) (tng) (tng) //讄游标的v始点
 (tng) (tng) (tng) query.setFirstResult(position);
 (tng) (tng) (tng) //讄游标的长?/span>
 (tng) (tng) (tng) query.setMaxResults(length);
 (tng) (tng) (tng) //记录生成
 (tng) (tng) (tng) List list = query.list();
 (tng) (tng) (tng) //把查询到的结果放入P代器
 (tng) (tng) (tng) iterator = list.iterator();
 (tng) (tng) (tng) return iterator;

 (tng) }


 (tng) ////////////////////////////////////////////////////////
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) /////以下部䆾带有审核功能 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ///// (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) ///
 (tng) ////////////////////////////////////////////////////////

 (tng) /**
 (tng)  (tng)* 取记录L
 (tng)  (tng)* @return int
 (tng)  (tng)* @param int isAuditing
 (tng)  (tng)*/

 (tng) publicint getInfosCount(int isAuditing)throwsException{
 (tng) (tng) (tng)


]]>
spring,hibernate,struts应用中的错误?qing)更?Q?Q?/title><link>http://m.tkk7.com/zhanglijun33/archive/2006/07/11/STRUTS3.html</link><dc:creator>无?/dc:creator><author>无?/author><pubDate>Tue, 11 Jul 2006 07:10:00 GMT</pubDate><guid>http://m.tkk7.com/zhanglijun33/archive/2006/07/11/STRUTS3.html</guid><wfw:comment>http://m.tkk7.com/zhanglijun33/comments/57650.html</wfw:comment><comments>http://m.tkk7.com/zhanglijun33/archive/2006/07/11/STRUTS3.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://m.tkk7.com/zhanglijun33/comments/commentRss/57650.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/zhanglijun33/services/trackbacks/57650.html</trackback:ping><description><![CDATA[q两天公怓Q务不紧,q样q我不做试验的机?x)和旉。今天的试验是在action里面写多个不同的Ҏ(gu)Qƈ且要?C务层的对象以便进一步处理数据?br />首先我的action要(h)承DispatchAction.q样才能实现多个不同的方法放在一个action里?br />2.在里面写入固定的Ҏ(gu)Q?br />public void setServlet(ActionServlet actionServlet){<br /> (tng) (tng) super.setServlet(actionServlet);<br /> (tng) (tng) ServletContext (tng) servletContext =actionServlet.getServletContext();<br /> (tng) WebApplicationContext wac = (tng) WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);<br />//然后可以得C务层的对象了(jin)。像我昨天说得那样做p。(注:(x)在这个方法里面可以得到多个不同对象,已经试验通过Q?br />然后再一个得到service对象的方法,以供后面的方法用?br />3.多个jsp面可以对应一个action吗?可以Q已l试验通过。ƈ且在struts_config.xml里面无须做Q何改动?br />4.myAction?method=addXX后面可以跟其他参数吗Q可以,已经试验通过?br />5Qjsp向action发出h的时候,Z么有时候出现空白异常?q时候你应该从两个方面进行检?br /> (tng) 1Q检查你的struts_config.xml forwordname<br /> (tng) (tng) 2以上l验是我苦想?jin)一天才得到的?img src ="http://m.tkk7.com/zhanglijun33/aggbug/57650.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhanglijun33/" target="_blank">无?/a> 2006-07-11 15:10 <a href="http://m.tkk7.com/zhanglijun33/archive/2006/07/11/STRUTS3.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts,hibernate,spring应用q程中的错误?qing)更正(每日更新Q?/title><link>http://m.tkk7.com/zhanglijun33/archive/2006/07/10/zongjie.html</link><dc:creator>无?/dc:creator><author>无?/author><pubDate>Mon, 10 Jul 2006 08:22:00 GMT</pubDate><guid>http://m.tkk7.com/zhanglijun33/archive/2006/07/10/zongjie.html</guid><wfw:comment>http://m.tkk7.com/zhanglijun33/comments/57522.html</wfw:comment><comments>http://m.tkk7.com/zhanglijun33/archive/2006/07/10/zongjie.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://m.tkk7.com/zhanglijun33/comments/commentRss/57522.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/zhanglijun33/services/trackbacks/57522.html</trackback:ping><description><![CDATA[上接“jsp面得到业务层的对象?br />1.我现在想用org.springframework.orm.hibernate.HibernateTransactionManager来给业务对象l入事务理Ҏ(gu)。但在调试的时候却发生?jin)异?Error registering bean with name 'myTransactionManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml],pȝ在给myTransactionManager Bean注册的时候却找不到它的类。的是很奇怪的问题QHibernateTransactionManager明明在q儿摆着嘛,怎么pȝ是找不到呢。经q几个小时的查找代码案Q发现原来我用的是Hibernate3版本。相应的org.springframework.orm.hibernate.HibernateTransactionManager也应该改成:(x)org.springframework.orm.hibernate3.HibernateTransactionManager.汗!javaE序员真累?br />2.错误2Q当我想在页面上得到l入事务理的service对象Ӟ又有一个错误来?jin)?x)<br />org.apache.jasper.JasperException: $Proxy2<br />org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)<br />晕吧Q代理h的待遇没问题?sh)(jin),可是它就是不l你做代理。经q在jsp面上的排察Q终于找到这一句:(x)<br /> (tng) (tng) RealnewsService newsservice=(RealnewsService)wac.getBean("newsService");<br />它有什么问题吗Q初学者看不出什么错误来Q因法上一炚w也没有,后来l高手指Ҏ(gu)如梦初醒Q?br />它的声明cd应该是相应的接口。这是spring一贯的风格Q(但这至于让我出错吗?郁闷Q,好。到今天为址Q我和关注我的博客的同学应该对spring应用E序的核?j)配|文件有?jin)一定的理解?jin)?br />ȝ一句话Q解决问题的Ҏ(gu)是:(x)来了(jin)问题?sh)要怕,用朴素的理念和执著的态度L胜bug (tng) ;-)<img src ="http://m.tkk7.com/zhanglijun33/aggbug/57522.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhanglijun33/" target="_blank">无?/a> 2006-07-10 16:22 <a href="http://m.tkk7.com/zhanglijun33/archive/2006/07/10/zongjie.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring 应用E序配置文g的核?j)理?/title><link>http://m.tkk7.com/zhanglijun33/archive/2006/07/06/spring.html</link><dc:creator>无?/dc:creator><author>无?/author><pubDate>Thu, 06 Jul 2006 03:29:00 GMT</pubDate><guid>http://m.tkk7.com/zhanglijun33/archive/2006/07/06/spring.html</guid><wfw:comment>http://m.tkk7.com/zhanglijun33/comments/56923.html</wfw:comment><comments>http://m.tkk7.com/zhanglijun33/archive/2006/07/06/spring.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://m.tkk7.com/zhanglijun33/comments/commentRss/56923.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/zhanglijun33/services/trackbacks/56923.html</trackback:ping><description><![CDATA[本文的理解来自实际应用程序。文件名是:(x)applicationContext-hibernate1.xml<br />熟?zhn)spring-hibernate架构的h对它肯定不陌生。它是由支持spring的组件在~程开始自动生成的Q但我们不能L停留在不不问的状态。否则对E序构造就没有更深一步的理解?br />如果理清applicationContext-hibernate1.xml的头l或者手工写它,对于d改进E序肯定是有益的?br />我ȝ出来的顺序是Q?br />1.建myDataSource<br />(org.apache.commons.dbcp.BasicDataSource).属性包括DBDriver,URL,UserName,Password.<br />2.mySessionFactory:<br />(org.springframework.orm.hibernate.LocalSessionFactoryBean)属性包括:(x)mappingResources(hbm.xml的集?QHibernateProperties,myDataSource(注入1).<br />3.myTransactionManager<br />(org.springframework.orm.hibernate.HibernateTransactionManager)mySessionFactory(注入2)<br />以上三步是后面各w|的基础。从后面开始我们就开始真正的配置我们的Beans?jin)?br />4.boDAO<br />(com.realnews.yourProject.service.dao.hibernate.boDAOs)注入mySessionFactory.<br />5.boTarget<br />(com.realnews.yourProject.service.spring.boServices) (tng)注入boDAO<br />6.boService<br />Qorg.springframework.transaction.interceptor.TransactionProxyFactoryBeanQ注入myTransactionManager?qing)boTarget<br />Qƈ用transactionAttributes讄数据库ƈ发控制别。例?br /><property name="transactionAttributes"><br /> (tng) (tng) (tng)<props><br /> (tng) (tng) (tng) (tng)<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop><br /> (tng) (tng) (tng) (tng)<prop key="save*">PROPAGATION_REQUIRED</prop><br /> (tng) (tng) (tng)</props><br />7.循环W?到第6步即可配|所有需要配|的bean.<br />本文不是摘抄Q如果想转摘Q请注明出处Q?a href="/zhanglijun33">m.tkk7.com/zhanglijun33</a><br />如果惌更详l的资料可以l我留言?br /><img src ="http://m.tkk7.com/zhanglijun33/aggbug/56923.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/zhanglijun33/" target="_blank">无?/a> 2006-07-06 11:29 <a href="http://m.tkk7.com/zhanglijun33/archive/2006/07/06/spring.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring Framework之最?jng)_践二 http://m.tkk7.com/zhanglijun33/archive/2006/07/05/lijun.html无?/dc:creator>无?/author>Wed, 05 Jul 2006 08:38:00 GMThttp://m.tkk7.com/zhanglijun33/archive/2006/07/05/lijun.htmlhttp://m.tkk7.com/zhanglijun33/comments/56805.htmlhttp://m.tkk7.com/zhanglijun33/archive/2006/07/05/lijun.html#Feedback2http://m.tkk7.com/zhanglijun33/comments/commentRss/56805.htmlhttp://m.tkk7.com/zhanglijun33/services/trackbacks/56805.html

Spring Framework最得以出名的是与Hibernate的无~链接,基本上用SpringQ就?x)用Hibernate。可惜的是Spring提供的HibernateTemplate功能昑־不够Q用v来也不是很方ѝ我们编E序Ӟ一般先写BusinessServiceQ由BusinessService调DAO来执行存储,在这斚wSpring没有很好的例子,造成真正想用好它Qƈ不容易?/font>

我们的思\是先写一个BaseDaoQ仿照HibernateTemplateQ将基本功能全部实现Q?/font>

public class BaseDao extends HibernateDaoSupport{

 (tng) (tng) (tng) private Log log = LogFactory.getLog(getClass());

 (tng) (tng) (tng) public Session openSession() {
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) return SessionFactoryUtils.getSession(getSessionFactory(), false);
 (tng) (tng) (tng) }

 (tng) (tng) (tng) public Object get(Class entityClass, Serializable id) throws DataAccessException {
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) Session session = openSession();
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) try {
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) return session.get(entityClass, id);
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) }
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) catch (HibernateException ex) {
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) throw SessionFactoryUtils.convertHibernateAccessException(ex);
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) }
 (tng) (tng) (tng) }

 (tng) (tng) (tng) public Serializable create(Object entity) throws DataAccessException {
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) Session session = openSession();
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) try {
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) return session.save(entity);
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) }
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) catch (HibernateException ex) {
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) throw SessionFactoryUtils.convertHibernateAccessException(ex);
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) }
 (tng) (tng) (tng) }

...

其它的DAOQ从BaseDaol承出来Q这样写其他的DAOQ代码就?x)很?/font>

从BaseDaol承出来EntityDaoQ专门负责一般实体的基本操作Q会(x)更方ѝ?/font>

public interface EntityDao {

 (tng) (tng) (tng) public Object get(Class entityClass, Serializable id) throws DataAccessException;

 (tng) (tng) (tng) public Object load(Class entityClass, Serializable id) throws DataAccessException;

 (tng) (tng) (tng) public Serializable create(Object entity) throws DataAccessException;
...}

/**
 (tng)* Base class for Hibernate DAOs. (tng) This class defines common CRUD methods for
 (tng)* child classes to inherit. User Sping AOP Inteceptor
 (tng)*/
public class EntityDaoImpl extends BaseDao implements EntityDao{

}

Z(jin)Transaction的控Ӟ采用AOP的方式:(x)

public interface EntityManager {

 (tng) (tng) (tng) public Object get(Class entityClass, Serializable id);

 (tng) (tng) (tng) public Object load(Class entityClass, Serializable id);

 (tng) (tng) (tng) public Serializable create(Object entity);
...

}

/**
 (tng)* Base class for Entity Service. User Sping AOP Inteceptor
 (tng)*/
public class EntityManagerImpl implements EntityManager {

 (tng) (tng) (tng) private EntityDao entityDao;

 (tng) (tng) (tng) public void setEntityDao(EntityDao entityDao) {
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) this.entityDao = entityDao;
 (tng) (tng) (tng) }

 (tng) (tng) (tng) public Object get(Class entityClass, Serializable id) {
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) return entityDao.get(entityClass, id);
 (tng) (tng) (tng) }

 (tng) (tng) (tng) public Object load(Class entityClass, Serializable id) {
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) return entityDao.load(entityClass, id);
 (tng) (tng) (tng) }
...

}

q样我们有?jin)一个通用的Hibernate实体引擎Q可以对MHibernate实体实现基本的增加、修攏V删除、查询等?/font>

其它的BusinessService可以(h)承EntityManagerQ快速实C务逻辑?/font>

具体XML配置如下Q?/font>

 (tng)<!-- Oracle JNDI DataSource for J2EE environments -->
 (tng)<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
 (tng) (tng)<property name="jndiName"><value>java:comp/env/jdbc/testPool</value></property>
 (tng)</bean>

 (tng)<!-- Hibernate SessionFactory for Oracle -->
 (tng)<!-- Choose the dialect that matches your "dataSource" definition -->
 (tng)<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
 (tng) (tng)<property name="dataSource"><ref local="dataSource"/></property>
 (tng) (tng)<property name="mappingResources">
 (tng) (tng) (tng)<value>user-hbm.xml</value>
 (tng) (tng)</property>
 (tng) (tng)<property name="hibernateProperties">
 (tng) (tng) (tng)<props>
 (tng) (tng) (tng) (tng)<prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
 (tng) (tng) (tng) (tng)<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.Provider</prop>
 (tng) (tng) (tng) (tng)<prop key="hibernate.cache.use_query_cache">true</prop>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <prop key="hibernate.show_sql">false</prop>
 (tng) (tng) (tng)</props>
 (tng) (tng)</property>
 (tng)</bean>

 (tng)<!-- AOP DAO Intecepter -->
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate.HibernateInterceptor">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <property name="sessionFactory">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref bean="sessionFactory"/>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) </bean>

 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <bean id="entityDaoTarget" class="com.gpower.services.entity.dao.EntityDaoImpl">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <property name="sessionFactory">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref bean="sessionFactory"/>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) </bean>

 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <bean id="entityDao" class="org.springframework.aop.framework.ProxyFactoryBean">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <property name="proxyInterfaces">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>com.gpower.services.entity.dao.EntityDao</value>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <property name="interceptorNames">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <list>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>hibernateInterceptor</value>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <value>entityDaoTarget</value>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) </list>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) </bean>

 (tng)<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
 (tng)<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
 (tng) (tng)<property name="sessionFactory"><ref local="sessionFactory"/></property>
 (tng)</bean>

 (tng)<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
 (tng)<!--
 (tng)<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
 (tng)-->

 (tng)<!-- Transactional proxy for the Application primary business object -->
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <bean id="entityManagerTarget" class="com.gpower.services.entity.EntityManagerImpl">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <property name="entityDao">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref bean="entityDao"/>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) </bean>

 (tng) (tng) (tng) (tng) (tng) (tng) (tng) <bean id="entityManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <property name="transactionManager">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref bean="transactionManager"/>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <property name="target">
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <ref bean="entityManagerTarget"/>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) <property name="transactionAttributes">
 (tng) (tng) (tng) (tng) <props>
 (tng) (tng) (tng) (tng) (tng) (tng) <prop key="get*">PROPAGATION_SUPPORTS</prop>
 (tng) (tng) (tng) (tng) (tng) (tng) <prop key="*">PROPAGATION_REQUIRED</prop>
 (tng) (tng) (tng) (tng) </props>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) (tng) </property>
 (tng) (tng) (tng) (tng) (tng) (tng) (tng) </bean>


Spring Framework之最?jng)_践二


]]>
վ֩ģ壺 ۺɫ߹ۿ| ɫWWWվ| һѸƵ| 鶹Ʒ͵Բ91| Ƶ߹ۿ| ޿ƬƵ| һƷ| 鶹ѹһ| ŮɫëƬѿ| Ƶ߹ۿ| 3pƵѹۿ| ձxxxxɫƵ߹ۿ| ޾Ʒ߹ۿ| þþþAVר| Ѹվ| һػaaëƬѹۿ| Ůһ18| ƷAһ| պƵ| ձ2019߹ۿ| Ļ߲| ޾ƷþavƬȥҲ| þþƷƷް| һһëƬ| ƷƵվ | ޾ƷĻ鶹 | AVAV˵ò| avr | һ| Ļ޾Ʒ| AVպAV̾ | ƷƵվ | ޾ƷƷ˿| ˽һ| wwwƵѿ| þѹۿƷ88av| ʮ˽Ļվ| ޵һۺר | AV߲Ų| AëƬþ| ˹վvƬѹۿ|