Persistência em Cascata com JPA

0 respostas
E

Jovens, estou com o problema informado acima, o meu detalhe que deveria levar o id do mater que é um sequence esta indo nulo.

Ele até gera o sequence, pois vejo no log. vejam abaixo:

@Entity

@Table(name = TB_CTT_EPT, schema = EP, uniqueConstraints = { @UniqueConstraint(columnNames = {

NUM_CTT_EPT, NUM_VRS_CTT_EPT }) })

@SequenceGenerator(name=seq, sequenceName=EP.COD_IDE_CTT_EPT)

public class ContratoEmprestimoDTO implements java.io.Serializable {

private Integer codIdeCttEpt;

private Set contratoEmprestimoValorDTOs = new HashSet(0);

@Id

@Column(name = COD_IDE_CTT_EPT, unique = true, nullable = false, insertable = true, updatable = true)

@GeneratedValue(strategy=GenerationType.SEQUENCE, generator=seq)

public Integer getCodIdeCttEpt() {

return this.codIdeCttEpt;

}
public void setCodIdeCttEpt(Integer codIdeCttEpt) {
	this.codIdeCttEpt = codIdeCttEpt;
}
@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "contratoEmprestimoDTO")
public Set<ContratoEmprestimoValorDTO> getContratoEmprestimoValorDTO() {
	return this.contratoEmprestimoValorDTOs;
}

public void setContratoEmprestimoValorDTO(Set<ContratoEmprestimoValorDTO> contratoEmprestimoValorDTOs) {
	this.contratoEmprestimoValorDTOs = contratoEmprestimoValorDTOs;
}

}

==========================================

@Entity

@Table(name = TB_CTT_EPT_VLR, schema = EP, uniqueConstraints = {})

public class ContratoEmprestimoValorDTO implements java.io.Serializable {

private ContratoEmprestimoValorId id;
private ContratoEmprestimoDTO contratoEmprestimoDTO;
@EmbeddedId
@AttributeOverrides( {
		@AttributeOverride(name = "codIdeCttEpt", column = @Column(name = "COD_IDE_CTT_EPT", unique = false, nullable = false, insertable = true, updatable = true)),
		@AttributeOverride(name = "codIdeTpoVlr", column = @Column(name = "COD_IDE_TPO_VLR", unique = false, nullable = false, insertable = true, updatable = true)) })
public ContratoEmprestimoValorId getId() {
	return this.id;
}

public void setId(ContratoEmprestimoValorId id) {
	this.id = id;
}

@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "COD_IDE_CTT_EPT", unique = false, nullable = false, insertable = false, updatable = false)
public ContratoEmprestimoDTO getContratoEmprestimoDTO() {
	return this.contratoEmprestimoDTO;
}

public void setContratoEmprestimoDTO(ContratoEmprestimoDTO contratoEmprestimoDTO) {
	this.contratoEmprestimoDTO = contratoEmprestimoDTO;
}

}

não entendi pq o id do contratoemprestimo vai nulo pra o contratoemprestimovalor

agradecido

Criado 3 de janeiro de 2007
Respostas 0
Participantes 1