Hibernate 1:n关系带来空值

时间:2013-02-08 19:10:56

标签: java hibernate

我有两个班级

Alocacao和Responsavel

我有1:n

Responsavel.class

@Entity
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@Table(name="Responsavel")
public class Responsavel {

@Id
@Column(name="idResp")
private int idResp;

@Column(name="nomeResp")
private String nomeResp;

@Column(name="emailResp")
private String email;

@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="idGrupResp")
private GrupoResponsavel grupo;

@Column(name="idPovUser")
private int povUser;

@ManyToMany(mappedBy="responsavel", fetch=FetchType.EAGER)
private List<TarefaBackLog> tarefa;

public Responsavel() {
    super();
}
//getters and setters

Alocacao.class

@Entity
@Table(name = "responsavel_alocacao")
public class Alocacao {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "idRespAloc")
private int idAlocacao;

@ManyToOne
@JoinColumn(name="idResponsavel", referencedColumnName="idResp")
private Responsavel idResponsavel;

@JoinColumn(name="idPeriodo")
private PeriodoPov idPeriodo;

@Column(name="Alocacao")
private double alocacao;
//getters and setters

但是当我尝试用“findAll()”获取所有Alocacao对象时,它会给idPeriodo和idResponsavel带来空值...任何想法?

由于

0 个答案:

没有答案