This is great progress then, because it means I was looking at the wrong part of the process. Being able to create a server in my cut-down example led me to believe the issue was a runtime one. But this information means that the issue is really an enhancement one! Still not sure how I am able to create a server though...
I will show you my cut-down example because it is simpler and shows how the _ebean_props for a child entity do not contain the properties from its
@MappedSuperclass parent. Here are the entity sources:
package beans;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
@MappedSuperclass
public class Parent {
@Column(name = "inheritedColumn")
private String inheritedColumn;
public String getInheritedColumn() {
return inheritedColumn;
}
public void setInheritedColumn(String inheritedColumn) {
this.inheritedColumn = inheritedColumn;
}
}
package beans;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "ImaginaryTable", schema = "imaginary_schema")
public class Child {
@Id
@Column(name = "id")
private Integer id;
}
Here are the enhanced class files, decompiled:
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package beans;
import io.ebean.bean.EntityBean;
import io.ebean.bean.EntityBeanIntercept;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
@MappedSuperclass
public class Parent implements EntityBean {
@Column(
name = "inheritedColumn"
)
private String inheritedColumn;
private static String _EBEAN_MARKER;
public static String[] _ebean_props = new String[]{"inheritedColumn"};
protected EntityBeanIntercept _ebean_intercept = new EntityBeanIntercept(this);
protected transient Object _ebean_identity;
public Parent() {
}
public String getInheritedColumn() {
return this._ebean_get_inheritedColumn();
}
public void setInheritedColumn(String inheritedColumn) {
this._ebean_set_inheritedColumn(inheritedColumn);
}
public String _ebean_getMarker() {
return _EBEAN_MARKER;
}
public String[] _ebean_getPropertyNames() {
return _ebean_props;
}
public String _ebean_getPropertyName(int pos) {
return _ebean_props[pos];
}
public EntityBeanIntercept _ebean_getIntercept() {
return this._ebean_intercept;
}
public EntityBeanIntercept _ebean_intercept() {
if (this._ebean_intercept == null) {
this._ebean_intercept = new EntityBeanIntercept(this);
}
return this._ebean_intercept;
}
protected String _ebean_get_inheritedColumn() {
this._ebean_intercept.preGetter(0);
return this.inheritedColumn;
}
protected void _ebean_set_inheritedColumn(String newValue) {
this._ebean_intercept.preSetter(true, 0, this._ebean_get_inheritedColumn(), newValue);
this.inheritedColumn = newValue;
}
protected String _ebean_getni_inheritedColumn() {
return this.inheritedColumn;
}
protected void _ebean_setni_inheritedColumn(String _newValue) {
this.inheritedColumn = _newValue;
this._ebean_intercept.setLoadedProperty(0);
}
public Object _ebean_getField(int index) {
switch(index) {
case 0:
return this.inheritedColumn;
default:
throw new RuntimeException("Invalid index " + index);
}
}
public Object _ebean_getFieldIntercept(int index) {
switch(index) {
case 0:
return this._ebean_get_inheritedColumn();
default:
throw new RuntimeException("Invalid index " + index);
}
}
public void _ebean_setField(int index, Object o) {
switch(index) {
case 0:
this._ebean_setni_inheritedColumn((String)o);
return;
default:
throw new RuntimeException("Invalid index " + index);
}
}
public void _ebean_setFieldIntercept(int index, Object o) {
switch(index) {
case 0:
this._ebean_set_inheritedColumn((String)o);
return;
default:
throw new RuntimeException("Invalid index " + index);
}
}
public void _ebean_setEmbeddedLoaded() {
}
public boolean _ebean_isEmbeddedNewOrDirty() {
return false;
}
public Object _ebean_newInstance() {
return new Parent();
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package beans;
import io.ebean.bean.EntityBean;
import io.ebean.bean.EntityBeanIntercept;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(
name = "ImaginaryTable",
schema = "imaginary_schema"
)
public class Child implements EntityBean {
@Id
@Column(
name = "id"
)
private Integer id;
private static String _EBEAN_MARKER;
public static String[] _ebean_props = new String[]{"id"};
protected EntityBeanIntercept _ebean_intercept = new EntityBeanIntercept(this);
protected transient Object _ebean_identity;
public Child() {
}
public String _ebean_getMarker() {
return _EBEAN_MARKER;
}
public String[] _ebean_getPropertyNames() {
return _ebean_props;
}
public String _ebean_getPropertyName(int pos) {
return _ebean_props[pos];
}
public EntityBeanIntercept _ebean_getIntercept() {
return this._ebean_intercept;
}
public EntityBeanIntercept _ebean_intercept() {
if (this._ebean_intercept == null) {
this._ebean_intercept = new EntityBeanIntercept(this);
}
return this._ebean_intercept;
}
protected Integer _ebean_get_id() {
this._ebean_intercept.preGetId();
return this.id;
}
protected void _ebean_set_id(Integer newValue) {
this._ebean_intercept.preSetter(false, 0, this.id, newValue);
this.id = newValue;
}
protected Integer _ebean_getni_id() {
return this.id;
}
protected void _ebean_setni_id(Integer _newValue) {
this.id = _newValue;
this._ebean_intercept.setLoadedProperty(0);
}
public Object _ebean_getField(int index) {
switch(index) {
case 0:
return this.id;
default:
throw new RuntimeException("Invalid index " + index);
}
}
public Object _ebean_getFieldIntercept(int index) {
switch(index) {
case 0:
return this._ebean_get_id();
default:
throw new RuntimeException("Invalid index " + index);
}
}
public void _ebean_setField(int index, Object o) {
switch(index) {
case 0:
this._ebean_setni_id((Integer)o);
return;
default:
throw new RuntimeException("Invalid index " + index);
}
}
public void _ebean_setFieldIntercept(int index, Object o) {
switch(index) {
case 0:
this._ebean_set_id((Integer)o);
return;
default:
throw new RuntimeException("Invalid index " + index);
}
}
private Object _ebean_getIdentity() {
synchronized(this) {
if (this._ebean_identity != null) {
return this._ebean_identity;
} else {
Object tmpId = this._ebean_getField(0);
if (tmpId != null) {
this._ebean_identity = tmpId;
} else {
this._ebean_identity = new Object();
}
return this._ebean_identity;
}
}
}
public boolean equals(Object obj) {
if (obj == null) {
return false;
} else if (!this.getClass().equals(obj.getClass())) {
return false;
} else {
return obj == this ? true : this._ebean_getIdentity().equals(((Child)obj)._ebean_getIdentity());
}
}
public int hashCode() {
return this._ebean_getIdentity().hashCode();
}
public void _ebean_setEmbeddedLoaded() {
}
public boolean _ebean_isEmbeddedNewOrDirty() {
return false;
}
public Object _ebean_newInstance() {
return new Child();
}
}
I also think the build.gradle would be interesting to see.
group 'mygroup'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
enhanceEbean
}
dependencies {
compile("io.ebean:ebean:11.7.1")
compile 'org.postgresql:postgresql:9.3-1103-jdbc4'
compile 'org.slf4j:slf4j-simple:1.7.21'
compile 'org.apache.openjpa:openjpa:1.2.1'
runtime files('src/resources')
enhanceEbean 'io.ebean:ebean-agent:11.5.1'
}
def enhanceEbean(entityClassDir, component) {
logger.lifecycle("Enhancing Ebean ${component} class files at " + file(entityClassDir))
ant.taskdef(
name: 'enhanceEbean'
, classname: "io.ebean.enhance.ant.AntEnhanceTask"
, classpath: configurations.enhanceEbean.asPath
)
def ebeanPackages = []
ebeanPackages << "beans/**"
ant.enhanceEbean(
classSource: entityClassDir
, packages: ebeanPackages.join(', ')
, transformArgs: "debug=3"
)
logger.lifecycle("Enhancing Ebean ${component} class files is finished.")
}
compileJava.doLast {
enhanceEbean("${buildDir}/classes/java/main", 'main')
}