i integrating spring , hibernate. spring.xml is:
<bean id="sessionfactory" class="org.springframework.orm.hibernate3.localsessionfactorybean"> <property name="datasource" ref="mydatasource" /> <property name="mappingresources"> <list> <value> resources/user.hbm.xml <!-- project.hbm.xml projcf.hbm.xml task.hbm.xml taskcf.hbm.xml category.hbm.xml taskestimation.hbm.xml projectestimation.hbm.xml parameter.hbm.xml statistictool.hbm.xml report.hbm.xml --> </value> </list> </property> <property name="hibernateproperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.hsqldialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">create</prop> </props> </property> </bean> <bean id="myuserdao" class="main.java.com.gwt.app.server.user"> <property name="sessionfactory" ref="sessionfactory" /> </bean> and on user class:
public void setsessionfactory(sessionfactory sessionfactory){ this.hibernatetemplate = new hibernatetemplate(sessionfactory); } public user loaduser(string log){ return (user)hibernatetemplate.load("user", log); } the problem hibernatetemplate null, me???? in advance!
you must not call new user() have ask spring bean (appcontext.getbean("myuserdao", user.class))
Comments
Post a Comment