I have a project in Java Web Application and the plan is to output the functionallity with Glassfish to PHP (nuSOAP) .
I have created my BD in mySQL , all tables , relationships, Primary Keys and Foreign Keys.
After that i open my NetBeans, New Project -> Java Web APP.
The steps that i made are
first create the Hibernate Configuration Wizard, and then , create Hibernate Reverse Engineering Wizard then the Hibernate mapping files and POJO's from Database and at the end HibernateUtil (named connection)
My entities are: Club one for many Grade one for many Team one for many Player
So, now i have all my Entities in my Java Project. And created a DAO for Club:
public List<Club> listClubs(){
try{
session.beginTransaction();
List<Club> listClub = (List<Club>)session.createQuery("from Club").list();
session.getTransaction().commit();
session.close();
return listClub;
}catch(Exception e){
System.out.println("Erro ao listar os clubes");
System.out.println(e.getMessage());
}
return null;
}
After that i want to create a WebService to output a list of All my Clubs.
@WebMethod(operationName = "listAllClubs")
public List<Club> listAllClubs() {
ClubDAO pdo = new ClubDAO();
List<Club> temp = pdo.listClubs();
System.out.println("[WS:::]Tamanho do array devolvido: " + temp.size());
return temp;
}
And after i tested my WebService in glassfish page i get this error:
> Service invocation threw an exception with message : null; Refer to the server log for more details
When i got the server log i see this:
> SEVERE: failed to lazily initialize a collection of role: pt.dai.entities.Club.grades, no session or session was closed
I already search about this error in internet, i already solved changing the xml of entity to default-lazy='false' but when this returns all club info to PHP my nuSOAP break up with a lot of DATA..
How can i use the lazzyLoad and send my data to WebService ?
Thanks for the help!