Fix for #173 - Ability to use a MappedSuperClass without being enhanced as long as it doesn't have persistent fields

This commit is contained in:
rbygrave
2014-07-19 17:49:03 +12:00
parent 2dca1bdf5b
commit 0c4fc4eea3
11 changed files with 165 additions and 61 deletions
@@ -0,0 +1,29 @@
package com.avaje.ebeaninternal.server.deploy;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.tests.model.basic.ResetBasicData;
import com.avaje.tests.model.mappedsuper.ASimpleBean;
public class TestNotEnhancedMappedSuper extends BaseTestCase {
@Test
public void simpleBean_mappedSuperNotEnhanced_ok() {
// //GlobalProperties.put("ebean.search.packages", "com.avaje.tests.model.mappedsuper");
ResetBasicData.reset();
ASimpleBean bean = new ASimpleBean();
bean.setName("junk");
Ebean.save(bean);
Assert.assertNotNull(bean.getId());
}
}
@@ -0,0 +1,30 @@
package com.avaje.tests.model.mappedsuper;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class ASimpleBean extends NotEnhancedMappedSuper {
@Id
Long id;
String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,32 @@
package com.avaje.tests.model.mappedsuper;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
@MappedSuperclass
public abstract class NotEnhancedMappedSuper {
public static String SOMETHING = "Hello";
private transient Long one;
@Transient
private Long two;
public Long getOne() {
return one;
}
public void setOne(Long one) {
this.one = one;
}
public Long getTwo() {
return two;
}
public void setTwo(Long two) {
this.two = two;
}
}