@Column(name="user_name",length=32)
private String user_name;
@Column(name="age")
private Integer age;
@Column(name="nice_name",length=32)
private String nice_name;
//属性实现......
}
UserDAO.javar,表 user 的一些操作,其中属性 sessionFactory 应该由 Spring 注入,如下:
package com.lei.demo.dao;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.Query;import org.hibernate.Session;import
org.hibernate.SessionFactory;import
org.springframework.stereotype.Repository;
import com.lei.demo.entity.Users;
public class UsersDAO {
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public SessionFactory getSessionFactory() {
return sessionFactory;
}