日期:2014-05-17 浏览次数:20650 次
@Service
@Transactional
public class LoginBo {
@Autowired
private HibDao hibDao;
public Object queryById(Class cls,String id){
return hibDao.queryById(cls, id);
}
public UserEntity queryByName(String userName){
String hsql = "from UserEntity t where t.userName="+userName;
List li = hibDao.query(hsql);
return (UserEntity) li.get(0);
}
}
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
<context:component-scan base-package="com.bo,com.dao" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">