Siden JPA 2.1 kan du bruge @ javax.persistence.ForeignKey anmærkning:
@OneToOne()
@JoinColumn(name="vehicle_id", referencedColumnName="vehicleId", [email protected](name = "Fk_userdetails_vehicle"))
public Vehicle getVehicle() {
return vehicle;
}
Før JPA 2.1 kunne du bruge Hibernates @org.hibernate.annotations.ForeignKey annotation, men denne er nu forældet:
@OneToOne()
@JoinColumn(name="vehicle_id", referencedColumnName="vehicleId")
@ForeignKey(name="Fk_userdetails_vehicle")
public Vehicle getVehicle() {
return vehicle;
}