Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Definition of embeddable class <em>should not</em> reference database table:</p> <pre><code>@Embeddable public class MovementData implements Serializable { private double speed; private Date timeOfPosition; private double latitude; private double longitude; private static final long serialVersionUID = 1L; public MovementData() { super(); } @Column(name="SPEED") public double getSpeed() { return this.speed; } ... @Column(name="TIME_OF_POSITION") public Date getTimeOfPosition() { return this.timeOfPosition; } ... @Column(name="LONGITUDE") public double getLongitude() { return this.longitude; } ... @Column(name="LATITUDE") public double getLatitude() { return this.latitude; } ... } </code></pre> <p>Then Vehicle entity should define secondary table for embedded structure <em>including join column</em>:</p> <pre><code>@Entity @Table(name="VEHICLE") @Inheritance(strategy=InheritanceType.JOINED) @SecondaryTable(name="MOVEMENT_DATA", pkJoinColumns = { @PrimaryKeyJoinColumn(name = "ID") } ) public class Vehicle implements Serializable { private int numWheels; private String color; private int id; private MovementData movementData; private static final long serialVersionUID = 1L; public Vehicle() { super(); } @Embedded @AttributeOverrides( { @AttributeOverride( name = "speed", column = @Column(name = "SPEED", table = "MOVEMENT_DATA") ), @AttributeOverride( name = "timeOfPosition", column = @Column(name = "TIME_OF_POSITION", table = "MOVEMENT_DATA") ), ... // override the rest of the attributes } ) public MovementData getMovementData() { return movementData; } ... @Id public int getId() { return this.id; } ... } </code></pre> <p>I hope this will work for you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload