Buenas dias
tengo que realizar un arbol dinamico en jsf mostrando de ccada nombre de personas sus viajes . Para ello tengo realizado lo siguiente
public class Person implements java.io.Serializable {
private int personid;
private String name;
private String jobtitle;
private Short frequentflyer;
private Date lastupdated;
private java.util.Set trips;
public Person() {
}
public Person(int personid) {
this.personid = personid;
}
public Person(int personid, String name, String jobtitle, Short frequentflyer, Date lastupdated) {
this.personid = personid;
this.name = name;
this.jobtitle = jobtitle;
this.frequentflyer = frequentflyer;
this.lastupdated = lastupdated;
}
public int getPersonid() {
return this.personid;
}
public void setPersonid(int personid) {
this.personid = personid;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getJobtitle() {
return this.jobtitle;
}
public void setJobtitle(String jobtitle) {
this.jobtitle = jobtitle;
}
public Short getFrequentflyer() {
return this.frequentflyer;
}
public void setFrequentflyer(Short frequentflyer) {
this.frequentflyer = frequentflyer;
}
public Date getLastupdated() {
return this.lastupdated;
}
public void setLastupdated(Date lastupdated) {
this.lastupdated = lastupdated;
}
/**
* @return the trips
*/
public java.util.Set getTrips() {
return trips;
}
/**
* @param trips the trips to set
*/
public void setTrips(java.util.Set trips) {
this.trips = trips;
}
}
-----
public class Trip implements java.io.Serializable {
private int tripid;
private int personid;
private Date depdate;
private String depcity;
private String destcity;
private int triptypeid;
private Date lastupdated;
public Trip() {
}
public Trip(int tripid, int personid, int triptypeid) {
this.tripid = tripid;
this.personid = personid;
this.triptypeid = triptypeid;
}
public Trip(int tripid, int personid, Date depdate, String depcity, String destcity, int triptypeid, Date lastupdated) {
this.tripid = tripid;
this.personid = personid;
this.depdate = depdate;
this.depcity = depcity;
this.destcity = destcity;
this.triptypeid = triptypeid;
this.lastupdated = lastupdated;
}
public int getTripid() {
return this.tripid;
}
public void setTripid(int tripid) {
this.tripid = tripid;
}
public int getPersonid() {
return this.personid;
}
public void setPersonid(int personid) {
this.personid = personid;
}
public Date getDepdate() {
return this.depdate;
}
public void setDepdate(Date depdate) {
this.depdate = depdate;
}
public String getDepcity() {
return this.depcity;
}
public void setDepcity(String depcity) {
this.depcity = depcity;
}
public String getDestcity() {
return this.destcity;
}
public void setDestcity(String destcity) {
this.destcity = destcity;
}
public int getTriptypeid() {
return this.triptypeid;
}
public void setTriptypeid(int triptypeid) {
this.triptypeid = triptypeid;
}
public Date getLastupdated() {
return this.lastupdated;
}
public void setLastupdated(Date lastupdated) {
this.lastupdated = lastupdated;
}
}
tengo en hibernate, para sacar los nombres de la persona y los viajes
try{
Session session =Hibernate.util.getCurrentSession();
Transaction tx=session.beginTransaction();
Query q =session.createQuery("from Person");
List personList=(List<Person>)q.list;
for(Person person:personList)
personList.getName();
Set s=personList.gettrips();
//Recorreria el set y sacaria los viajes
---
}catch(Exception e{
e.printStackTrace();
Me da error el codigo, ¿se puede hacer así?
Mi pregunta en que estructura de datos me aconsejais que guarde el nombre de la persona y los viajes(list,array,....)para despues crear el arbol dinámico.Soy nueva en hibernate.Espero que me ayudeis