Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我的删除方法不会在@OneToOne关系中删除_Java_Spring_Hibernate - Fatal编程技术网

Java 我的删除方法不会在@OneToOne关系中删除

Java 我的删除方法不会在@OneToOne关系中删除,java,spring,hibernate,Java,Spring,Hibernate,我有一个1:1的Moneda和Remesa关系,但当我去删除Moneda或Remesa时,也不会删除我,我没有得到任何错误,只是它们没有在数据库中删除。我的表中的其他关系运行良好。我不知道这是否是因为我与@OneToOne的关系有问题 Moneda.java 同样的事情发生在雷米萨身上,方法实际上是相同的。这可能是两个表之间的关系有问题吗?你能粘贴实体吗?@Andronicus我已经编辑了这个问题我不这么认为,没有任何带有@Id的注释你现在拥有了一切@Andronicus @Id @Sequen

我有一个1:1的Moneda和Remesa关系,但当我去删除Moneda或Remesa时,也不会删除我,我没有得到任何错误,只是它们没有在数据库中删除。我的表中的其他关系运行良好。我不知道这是否是因为我与@OneToOne的关系有问题

Moneda.java


同样的事情发生在雷米萨身上,方法实际上是相同的。这可能是两个表之间的关系有问题吗?

你能粘贴实体吗?@Andronicus我已经编辑了这个问题我不这么认为,没有任何带有
@Id的注释
你现在拥有了一切@Andronicus
@Id
@SequenceGenerator(name = "moneda_sequence", sequenceName = "moneda_sequence", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "moneda_sequence")
@Column(name = "ID")
@JsonProperty("id")
private Long id;

@Column(name = "FECHA_INSERCION")
@JsonProperty("fechaInsercion")
@JsonDeserialize(using = JsonDateDeserializer.class)
@JsonSerialize(using = JsonDateSerializer.class)
private LocalDateTime fechaInsercion;

@Column(name = "FECHA_MODIFICACION")
@JsonProperty("fechaModificacion")
@JsonDeserialize(using = JsonDateDeserializer.class)
@JsonSerialize(using = JsonDateSerializer.class)
private LocalDateTime fechaModificacion;

@Column(name = "NOMBRE")
@JsonProperty("nombre")
private String nombre;

@Column(name = "ABREVIATURA")
@JsonProperty("abreviatura")
private String abreviatura;

@OneToOne
@JoinColumn(name = "pais", nullable = true)
@JsonProperty("pais")
private Pais pais;

@OneToMany(mappedBy = "moneda", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
private Set<Corresponsable> corresponsables;

@OneToMany(mappedBy = "moneda", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
private Set<Documento> documentos;

@OneToOne(mappedBy = "moneda", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
private Remesa remesa;
@Id
@SequenceGenerator(name = "remesa_sequence", sequenceName = "remesa_sequence", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "remesa_sequence")
@Column(name = "ID")
private Long id;

@Column(name = "FECHA_INSERCION")
@JsonDeserialize(using = JsonDateDeserializer.class)
@JsonSerialize(using = JsonDateSerializer.class)
private LocalDateTime fechaInsercion;

@Column(name = "FECHA_MODIFICACION")
@JsonDeserialize(using = JsonDateDeserializer.class)
@JsonSerialize(using = JsonDateSerializer.class)
private LocalDateTime fechaModificacion;

private Integer tipoDoc;
private Integer entidad;
private Integer oficina;
private Integer referencia;
@OneToMany(mappedBy = "remesa", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
private Set<Documento> documento;

@OneToOne(mappedBy = "remesa", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
private EnvioRemesa envio_id;

    @OneToOne
    @JoinColumn (name = "moneda_id", nullable = true)
    private Moneda moneda;
public void getDeleteMoneda (Long moneda_id) {
        try {
            Moneda m = monedaRepo.findById(moneda_id).orElseThrow (() -> new Exception ("bad"));
            if (m! = null) {
                monedaRepo.deleteById (moneda_id); // HERE RETURN NULL DEBUGGING BUT THERE IS A MONEDA WITH THAT ID
            }
        } catch (Exception e) {
            
            e.printStackTrace ();
        }
}