Problem with Hibernate Join

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top