Hey, i have ran into a small problem
Code:
javax.servlet.ServletException: /pages/dataTable.jsp(17,13) '#{item.name}' Error reading 'name' on type client.Client$$EnhancerByCGLIB$$11ebbbea
javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
My bean is:
Code:
package client;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class getFromDB {
/**
* @param args
*/
private List<Client> clients;
public String setData() {
Session session = null;
String name = "algus";
//Hibernate.initialize(Client.getName());
try{
clients = new ArrayList<Client>();
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
//Using from Clause
String SQL_QUERY ="from Client";
Query query = session.createQuery(SQL_QUERY);
for(Iterator it=query.iterate();it.hasNext();){
Client contact=(Client)it.next();
//Set hobbies = contact.getHobbies();
//System.out.println("Nimi: " + contact.getName());
//for (Iterator i = hobbies.iterator(); i.hasNext(); ) {
//Hobby hobby = (Hobby)i.next();
//System.out.println("Hobi: " + hobby.getName());
//}
clients.add(contact);
}
session.close();
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
}
this.clients = clients;
return "success";
}
public List<Client> getClients(){
return clients;
}
}
I now know i have to initialize it somehow, but where do i place the code to initialize?