mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#513 - Column Constraint for Enum types should cover all Enum values in an inheritance hierachy
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.avaje.tests.model.basic;
|
||||
|
||||
import com.avaje.ebean.annotation.DbEnumValue;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
@@ -14,7 +16,22 @@ import java.util.Set;
|
||||
@DiscriminatorValue("C")
|
||||
public class Car extends Vehicle {
|
||||
|
||||
private static final long serialVersionUID = 4716705779684333446L;
|
||||
public enum Size {
|
||||
SMALL("S"),
|
||||
LARGE("L");
|
||||
|
||||
String value;
|
||||
Size(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@DbEnumValue
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private Size size;
|
||||
|
||||
private String driver;
|
||||
|
||||
@@ -58,4 +75,12 @@ public class Car extends Vehicle {
|
||||
public void setAccessories(Set<CarAccessory> accessories) {
|
||||
this.accessories = accessories;
|
||||
}
|
||||
|
||||
public Size getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Size size) {
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.avaje.tests.model.basic;
|
||||
|
||||
import com.avaje.ebean.annotation.DbEnumValue;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
@@ -10,7 +12,24 @@ import javax.persistence.ManyToOne;
|
||||
@DiscriminatorValue("T")
|
||||
public class Truck extends Vehicle {
|
||||
|
||||
private static final long serialVersionUID = 7433386912403859900L;
|
||||
public enum Size {
|
||||
SMALL("S"),
|
||||
MEDIUM("M"),
|
||||
LARGE("L"),
|
||||
HUGE("H");
|
||||
|
||||
String value;
|
||||
Size(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@DbEnumValue
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private Size size;
|
||||
|
||||
@ManyToOne
|
||||
TruckRef truckRef;
|
||||
@@ -33,4 +52,11 @@ public class Truck extends Vehicle {
|
||||
this.truckRef = truckRef;
|
||||
}
|
||||
|
||||
public Size getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Size size) {
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user