Attempt to create test case for #281 - test case not failing

This commit is contained in:
rbygrave
2015-04-30 20:30:12 +12:00
parent 0356067d86
commit 4f67d2be4e
4 changed files with 90 additions and 0 deletions
@@ -729,6 +729,9 @@ public class DeployBeanDescriptor<T> {
return null;
}
String selectClause = sb.toString();
if (selectClause.length() == 0) {
throw new IllegalStateException("Bean " + getFullName() + " has no properties?");
}
return selectClause.substring(0, selectClause.length() - 1);
}
@@ -0,0 +1,43 @@
package com.avaje.tests.inheritance;
import javax.persistence.*;
/**
*/
@Entity
public class InnerReport {
@Id
Long id;
String name;
@OneToOne
Forecast forecast;
public Forecast getForecast() {
return forecast;
}
public void setForecast(Forecast forecast) {
this.forecast = forecast;
}
@Entity
@DiscriminatorValue("F")
public static class Forecast extends Stockforecast {
@ManyToOne
InnerReport innerReport;
public InnerReport getInnerReport() {
return innerReport;
}
public void setInnerReport(InnerReport innerReport) {
this.innerReport = innerReport;
}
}
}
@@ -0,0 +1,21 @@
package com.avaje.tests.inheritance;
import javax.persistence.*;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING)
public abstract class Stockforecast {
@Id
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
@@ -0,0 +1,23 @@
package com.avaje.tests.inheritance;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import org.junit.Test;
public class TestNpeOnDiscriminator extends BaseTestCase {
@Test
public void test() {
InnerReport report = Ebean.json().toBean(InnerReport.class, "{}");
Ebean.save(report);
// other service ...
InnerReport.Forecast f = new InnerReport.Forecast();
report.setForecast(f);
f.innerReport = report;
Ebean.save(f);
}
}