春季/休眠未找到任何记录

I'm using hibernate with spring and i can't get some data from my database, i'm trying to list user objects in a primefaces p:datatable.

在我的控制台中,它在FillUsersList中引发异常:java.lang.NullPointerException Erreur dans usersList

(spring 3.2,hibernate 4.2,jsf 2.1)

Managedbean:

@Autowired
    UserService userService;
// Used to fetch all records  
@PostConstruct  
public void fillUsersList(){                   
try{  
    usersList = userService.getAllUsers();  
}catch(Exception e){  
System.out.println(e+"Erreur dans usersList");  
}  
} 


        public List<DemUser> getUsersList() {
            return usersList;
        }
        public void setUsersList(List<DemUser> usersList) {
            this.usersList = usersList;
        }

道:

@SuppressWarnings("unchecked")
public List<DemUser> getAllUsers() {
    try {
        return sessionFactory.getCurrentSession().createQuery("from DemUser")
                .list();
 } catch (RuntimeException re) {
    System.out.printf("*** return All users failed", re);
     throw re;
 }
}

JSF:

<p:dataTable var="u" value="#{UserBean.usersList}" >
    <p:column headerText="Name">
        <h:outputText value="#{u.nameUser}" />
    </p:column>
</p:dataTable>
评论