C
Cacho
Hi
I've a problem with Hibernate.
I want to get data from a join so I did:
--------------
@Entity
@Table(name = "periodos")
public class Periodos implements Serializable {
private int id_per;
/** Used to join tables */
private Set<Horarios> periodosHorarios;
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(
name="PeriodosHorarios",
joinColumns = { @JoinColumn( name="id_per") },
inverseJoinColumns = @JoinColumn( name="id_horarios")
)
public Set<Horarios> getPeriodosHorarios() {
return periodosHorarios;
}
public void setPeriodosHorarios(Set<Horarios> periodosHorarios) {
this.periodosHorarios = periodosHorarios;
}
------------
and
----------
@Entity
@Table(name = "horarios")
public class Horarios implements Serializable {
/**
* PK.
*/
private int id_horarios;
/**
* FK to periodos.
*/
private int id_per;
@Column(name = "id_per", nullable = false, unique = false)
public int getId_per() {
return id_per;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public int getId_horarios() {
return id_horarios;
}
-------------
I guess everything is ok, but when data is retrieved I receive my Set
property empty. Nevertheless, I can see in MySQL logs that Hibernate
did the query well and recovered data.
Am I forgetting something to declare ? How could I solve the problem ?
Thanks in advance
C
I've a problem with Hibernate.
I want to get data from a join so I did:
--------------
@Entity
@Table(name = "periodos")
public class Periodos implements Serializable {
private int id_per;
/** Used to join tables */
private Set<Horarios> periodosHorarios;
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(
name="PeriodosHorarios",
joinColumns = { @JoinColumn( name="id_per") },
inverseJoinColumns = @JoinColumn( name="id_horarios")
)
public Set<Horarios> getPeriodosHorarios() {
return periodosHorarios;
}
public void setPeriodosHorarios(Set<Horarios> periodosHorarios) {
this.periodosHorarios = periodosHorarios;
}
------------
and
----------
@Entity
@Table(name = "horarios")
public class Horarios implements Serializable {
/**
* PK.
*/
private int id_horarios;
/**
* FK to periodos.
*/
private int id_per;
@Column(name = "id_per", nullable = false, unique = false)
public int getId_per() {
return id_per;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public int getId_horarios() {
return id_horarios;
}
-------------
I guess everything is ok, but when data is retrieved I receive my Set
property empty. Nevertheless, I can see in MySQL logs that Hibernate
did the query well and recovered data.
Am I forgetting something to declare ? How could I solve the problem ?
Thanks in advance
C