如何通过@EmbeddedId将PFK中的数据保存为@embeddable。在Java中

时间:2017-12-05 13:32:05

标签: hibernate jpa java-ee

我在java中使用embeddable映射具有PFK的表,但是当我运行合并以更新来自外表甚至映射级联的数据时,它不执行更新。有人能帮助我吗?

遵循课程代码

@Entity
@Table(name = "SAIDA_ESTACIONAMENTO")
public class SaidaEstacionamento extends EntidadeEstacionamento {

private static final long serialVersionUID = 1L;

@EmbeddedId
private SaidaEstacionamentoId id;

@Column(name = "SAIDA_DATA_FINAL", columnDefinition = "datetime default current_datetime", nullable = true)
@Temporal(TemporalType.TIMESTAMP)
private Date dataSaidaFinal;

@Column(name = "SAIDA_DATA_FINAL_SENSOR", columnDefinition = "DATETIME", nullable = true)
@Temporal(TemporalType.DATE)
private Date dataSaidaFinalSensor;

@Column(name = "SAIDA_HORA_TOTAL", columnDefinition = "TIME", nullable = true)
@Temporal(TemporalType.TIME)
private Date horaTotal;

@Column(name = "SAIDA_STATUS", columnDefinition = "NUMBER", length = 1, nullable = true)
private Integer saidaStatus;



@Embeddable
public class SaidaEstacionamentoId implements Serializable {

private static final long serialVersionUID = 1L;

@JoinColumn(name = "ID_SAIDA_ESTACIONAMENTO", nullable = false)
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, targetEntity = EntradaEstacionamento.class)
private EntradaEstacionamento entradaEstacionamento;




@Entity
@Table(name = "ENTRADA_ESTACIONAMENTO")
public class EntradaEstacionamento extends EntidadeEstacionamento {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID_ENTRADA_ESTACIONAMENTO", columnDefinition = "NUMBER", length = 10, nullable = false)
private Long id;

@Column(name = "ENTRADA_DATA_INICIAL", columnDefinition = "DATETIME", nullable = true)
@Temporal(TemporalType.TIMESTAMP)
private Date dataEntradaInicial;

0 个答案:

没有答案