<!-- Dao是无状态的 是单例的 scope="singleton"
<bean id="userDao" class="com.test.dao.impl.UserDAOImpl"
scope="singleton">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean> <bean id="userService"
class="com.test.service.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean>
-->
<!--控制层-->
<!--id="saveUserAction" 别名--><!-- scope:prototype 生产新的action-->
<bean id="listUserAction"
class="com.test.action.user.ListUserAction" scope="prototype">
<property name="service" ref="userService"></property>
</bean>现在不定义接口了,就是那个 userDao和userService 没了,注释部分怎么改写啊??
<bean id="userDao" class="com.test.dao.impl.UserDAOImpl"
scope="singleton">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean> <bean id="userService"
class="com.test.service.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean>
-->
<!--控制层-->
<!--id="saveUserAction" 别名--><!-- scope:prototype 生产新的action-->
<bean id="listUserAction"
class="com.test.action.user.ListUserAction" scope="prototype">
<property name="service" ref="userService"></property>
</bean>现在不定义接口了,就是那个 userDao和userService 没了,注释部分怎么改写啊??
---
package com.test.dao;import java.util.List;import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.test.bean.User;public class UserDAO extends HibernateDaoSupport
{ @SuppressWarnings("unchecked")
public List<User> findAllUsers()
{
String hql = "from User user order by user.id ";
return (List<User>)this.getHibernateTemplate().find(hql);
}
public User findUserById(Integer id)
{
User user = (User) this.getHibernateTemplate().get(User.class, id);
return user;
}}UserService.java
-----import com.test.bean.User;
import com.test.dao.UserDAO;public class UserService
{
private UserDAO userDao;
public UserDAO getUserDao() {
return userDao;
} public void setUserDao(UserDAO userDao) {
this.userDao = userDao;
}
public List<User> findAll()
{
return this.userDao.findAllUsers();
} public User findById(Integer id)
{
return this.userDao.findUserById(id);
}
}
---
package com.test.dao;import java.util.List;import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.test.bean.User;public class UserDAO extends HibernateDaoSupport
{@SuppressWarnings("unchecked")
public List<User> findAllUsers()
{
String hql = "from User user order by user.id ";
return (List<User>)this.getHibernateTemplate().find(hql);
}
public User findUserById(Integer id)
{
User user = (User) this.getHibernateTemplate().get(User.class, id);
return user;
}}//UserService.java
-----import com.test.bean.User;
import com.test.dao.UserDAO;public class UserService
{
private UserDAO userDao;
public UserDAO getUserDao() {
return userDao;
}public void setUserDao(UserDAO userDao) {
this.userDao = userDao;
}
public List<User> findAll()
{
return this.userDao.findAllUsers();
}public User findById(Integer id)
{
return this.userDao.findUserById(id);
}
<property name="jsglService">
<ref bean="jsglService" />
</property>
</bean>
<bean id="jsglService" parent="baseTransactionProxyBean" >
<property name="target" >
<bean class="com.asideal.struts.jsgl.service.JsglService" autowire="byName">
<property name="jsglDao">
<ref bean="jsDao"/>
</property>
</bean>
</property>
</bean>
<bean id="jsDao" class="com.asideal.struts.jsgl.dao.JsglDao">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>