mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Fix for #77 - NPE when lazy loading on a OneToMany that is not a leaf
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.avaje.tests.model.inheritmany;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class IMRelated {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
IMRoot owner;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public IMRoot getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(IMRoot owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.avaje.tests.model.inheritmany;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
public class IMRoot {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@OneToMany(mappedBy="owner")
|
||||
List<IMRelated> related;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<IMRelated> getRelated() {
|
||||
return related;
|
||||
}
|
||||
|
||||
public void setRelated(List<IMRelated> related) {
|
||||
this.related = related;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.avaje.tests.model.inheritmany;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
@DiscriminatorValue("ONE")
|
||||
public class IMRootOne extends IMRoot {
|
||||
|
||||
String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.avaje.tests.model.inheritmany;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
@DiscriminatorValue("TWO")
|
||||
public class IMRootTwo extends IMRoot {
|
||||
|
||||
String title;
|
||||
|
||||
Date whenTitle;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Date getWhenTitle() {
|
||||
return whenTitle;
|
||||
}
|
||||
|
||||
public void setWhenTitle(Date whenTitle) {
|
||||
this.whenTitle = whenTitle;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user