Fix mappings
This commit is contained in:
parent
87ffe9dc51
commit
6db6c6b2e5
@ -8,13 +8,10 @@ import java.util.Collection;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Driver extends PlatformUser implements IDriver {
|
public class Driver extends PlatformUser implements IDriver {
|
||||||
@OneToMany(targetEntity = Match.class)
|
|
||||||
private Collection<IMatch> matches = new ArrayList<>();
|
|
||||||
|
|
||||||
@ManyToOne(targetEntity = Vehicle.class, optional = false)
|
@ManyToOne(targetEntity = Vehicle.class, optional = false)
|
||||||
private IVehicle vehicle;
|
private IVehicle vehicle;
|
||||||
|
|
||||||
@OneToMany(targetEntity = Employment.class)
|
@ManyToMany(targetEntity = Employment.class)
|
||||||
private Collection<IEmployment> employments = new ArrayList<>();
|
private Collection<IEmployment> employments = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -1,19 +1,16 @@
|
|||||||
package dst.ass1.jpa.model.impl;
|
package dst.ass1.jpa.model.impl;
|
||||||
|
|
||||||
import dst.ass1.jpa.model.IDriver;
|
|
||||||
import dst.ass1.jpa.model.IEmployment;
|
import dst.ass1.jpa.model.IEmployment;
|
||||||
import dst.ass1.jpa.model.IEmploymentKey;
|
import dst.ass1.jpa.model.IEmploymentKey;
|
||||||
import dst.ass1.jpa.model.IOrganization;
|
|
||||||
import org.hibernate.annotations.Target;
|
import org.hibernate.annotations.Target;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import static dst.ass1.jpa.util.Constants.T_DRIVER;
|
|
||||||
import static dst.ass1.jpa.util.Constants.T_ORGANIZATION;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Employment implements IEmployment {
|
public class Employment implements IEmployment, Serializable {
|
||||||
@EmbeddedId @Target(EmploymentKey.class)
|
@EmbeddedId @Target(EmploymentKey.class)
|
||||||
private IEmploymentKey id;
|
private IEmploymentKey id;
|
||||||
|
|
||||||
@ -21,14 +18,6 @@ public class Employment implements IEmployment {
|
|||||||
|
|
||||||
private Boolean active;
|
private Boolean active;
|
||||||
|
|
||||||
@MapsId(T_ORGANIZATION)
|
|
||||||
@ManyToOne(targetEntity = Organization.class)
|
|
||||||
IOrganization organization;
|
|
||||||
|
|
||||||
@MapsId(T_DRIVER)
|
|
||||||
@ManyToOne(targetEntity = Driver.class)
|
|
||||||
IDriver driver;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEmploymentKey getId() {
|
public IEmploymentKey getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import dst.ass1.jpa.model.IOrganization;
|
|||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public class EmploymentKey implements IEmploymentKey, Serializable {
|
public class EmploymentKey implements IEmploymentKey, Serializable {
|
||||||
@ -17,9 +16,6 @@ public class EmploymentKey implements IEmploymentKey, Serializable {
|
|||||||
@ManyToOne(targetEntity = Organization.class)
|
@ManyToOne(targetEntity = Organization.class)
|
||||||
private IOrganization organization;
|
private IOrganization organization;
|
||||||
|
|
||||||
public EmploymentKey() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDriver getDriver() {
|
public IDriver getDriver() {
|
||||||
return driver;
|
return driver;
|
||||||
@ -39,17 +35,4 @@ public class EmploymentKey implements IEmploymentKey, Serializable {
|
|||||||
public void setOrganization(IOrganization organization) {
|
public void setOrganization(IOrganization organization) {
|
||||||
this.organization = organization;
|
this.organization = organization;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
EmploymentKey that = (EmploymentKey) o;
|
|
||||||
return getDriver().equals(that.getDriver()) && getOrganization().equals(that.getOrganization());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(getDriver(), getOrganization());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,9 +16,6 @@ public class Location implements ILocation {
|
|||||||
|
|
||||||
private Long locationId;
|
private Long locationId;
|
||||||
|
|
||||||
@ManyToMany(targetEntity = Trip.class)
|
|
||||||
private Collection<ITrip> trips = new ArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package dst.ass1.jpa.model.impl;
|
package dst.ass1.jpa.model.impl;
|
||||||
|
|
||||||
import dst.ass1.jpa.model.*;
|
import dst.ass1.jpa.model.*;
|
||||||
|
import org.hibernate.annotations.Target;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -12,16 +13,16 @@ public class Match implements IMatch {
|
|||||||
|
|
||||||
private Date date;
|
private Date date;
|
||||||
|
|
||||||
@Embedded
|
@Embedded @Target(Money.class)
|
||||||
private IMoney fare;
|
private IMoney fare;
|
||||||
|
|
||||||
@OneToOne(targetEntity = Trip.class)
|
@OneToOne(targetEntity = Trip.class)
|
||||||
private ITrip trip;
|
private ITrip trip;
|
||||||
|
|
||||||
@ManyToOne(targetEntity = Vehicle.class)
|
@OneToOne(targetEntity = Vehicle.class)
|
||||||
private IVehicle vehicle;
|
private IVehicle vehicle;
|
||||||
|
|
||||||
@ManyToOne(targetEntity = Driver.class)
|
@OneToOne(targetEntity = Driver.class)
|
||||||
private IDriver driver;
|
private IDriver driver;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -3,12 +3,12 @@ package dst.ass1.jpa.model.impl;
|
|||||||
import dst.ass1.jpa.model.IMoney;
|
import dst.ass1.jpa.model.IMoney;
|
||||||
|
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public class Money implements IMoney {
|
public class Money implements IMoney, Serializable {
|
||||||
private String currency;
|
private String currency;
|
||||||
|
|
||||||
private BigDecimal value;
|
private BigDecimal value;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -6,16 +6,13 @@ import dst.ass1.jpa.model.ITrip;
|
|||||||
import org.hibernate.annotations.Cascade;
|
import org.hibernate.annotations.Cascade;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import static dst.ass1.jpa.util.Constants.*;
|
import static dst.ass1.jpa.util.Constants.*;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(
|
@Table(uniqueConstraints = @UniqueConstraint(columnNames = {M_RIDER_ACCOUNT, M_RIDER_BANK_CODE}))
|
||||||
uniqueConstraints = @UniqueConstraint(columnNames = {M_RIDER_ACCOUNT, M_RIDER_BANK_CODE})
|
|
||||||
)
|
|
||||||
public class Rider extends PlatformUser implements IRider {
|
public class Rider extends PlatformUser implements IRider {
|
||||||
@Column(unique = true) @NotNull
|
@Column(unique = true) @NotNull
|
||||||
private String email;
|
private String email;
|
||||||
@ -34,7 +31,7 @@ public class Rider extends PlatformUser implements IRider {
|
|||||||
@JoinColumn(name = I_PREFERENCES, unique = true)
|
@JoinColumn(name = I_PREFERENCES, unique = true)
|
||||||
private IPreferences preferences;
|
private IPreferences preferences;
|
||||||
|
|
||||||
@ManyToOne(targetEntity = Trip.class)
|
@OneToMany(targetEntity = Trip.class)
|
||||||
private Collection<ITrip> trips = new ArrayList<>();
|
private Collection<ITrip> trips = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package dst.ass1.jpa.model.impl;
|
|||||||
import dst.ass1.jpa.model.IMoney;
|
import dst.ass1.jpa.model.IMoney;
|
||||||
import dst.ass1.jpa.model.ITrip;
|
import dst.ass1.jpa.model.ITrip;
|
||||||
import dst.ass1.jpa.model.ITripInfo;
|
import dst.ass1.jpa.model.ITripInfo;
|
||||||
|
import org.hibernate.annotations.Target;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -16,7 +17,7 @@ public class TripInfo implements ITripInfo {
|
|||||||
|
|
||||||
private Double distance;
|
private Double distance;
|
||||||
|
|
||||||
@Embedded
|
@Embedded @Target(Money.class)
|
||||||
private IMoney total;
|
private IMoney total;
|
||||||
|
|
||||||
private Integer driverRating;
|
private Integer driverRating;
|
||||||
|
|||||||
@ -20,15 +20,6 @@ public class Vehicle implements IVehicle {
|
|||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
@OneToMany(targetEntity = Driver.class)
|
|
||||||
private Collection<IDriver> driver;
|
|
||||||
|
|
||||||
@OneToMany(targetEntity = Match.class)
|
|
||||||
private Collection<IMatch> match;
|
|
||||||
|
|
||||||
@ManyToMany(mappedBy = "vehicles", targetEntity = Organization.class)
|
|
||||||
private Collection<IOrganization> organization;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user