Home How to save data in PFK mapped as @embeddable through @EmbeddedId. In Java
Reply: 0

How to save data in PFK mapped as @embeddable through @EmbeddedId. In Java

Isaac Nascimento
1#
Isaac Nascimento Published in 2017-12-05 13:32:05Z

I am mapping a table that has PFK using embeddable in java, but when I run the merge to update the data from the foreign table even mapping cascade, it does not perform the update. Can someone help me?

Follow the class code

@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;
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301772 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO