Home > AI > Backend > SpringBoot > mysql-connector-java >

@JoinColumns

@Entity
 class Office {
    @Id
    private Integer id;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumns({
            @JoinColumn(name="ADDR_ID", referencedColumnName="ID"),
            @JoinColumn(name="ADDR_ZIP", referencedColumnName="ZIP")
    })
    private Address address;
}

@Entity
class Address {
    @Id
    private Integer id;

    private String zip;
}

Leave a Reply