mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#592 - Fetched empty collection of null child of parent entity
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.avaje.tests.model.tevent;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
public class TEvent {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToOne(mappedBy = "event")
|
||||
TEventOne one;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
public TEvent(String name) {
|
||||
this.name = 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;
|
||||
}
|
||||
|
||||
public TEventOne getOne() {
|
||||
return one;
|
||||
}
|
||||
|
||||
public void setOne(TEventOne one) {
|
||||
this.one = one;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.avaje.tests.model.tevent;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
public class TEventMany {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String many;
|
||||
|
||||
@ManyToOne
|
||||
TEventOne one;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMany() {
|
||||
return many;
|
||||
}
|
||||
|
||||
public void setMany(String many) {
|
||||
this.many = many;
|
||||
}
|
||||
|
||||
public TEventOne getOne() {
|
||||
return one;
|
||||
}
|
||||
|
||||
public void setOne(TEventOne one) {
|
||||
this.one = one;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.avaje.tests.model.tevent;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Version;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class TEventOne {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String one;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
@OneToOne
|
||||
TEvent event;
|
||||
|
||||
@OneToMany(mappedBy = "one")
|
||||
List<TEventMany> many;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getOne() {
|
||||
return one;
|
||||
}
|
||||
|
||||
public void setOne(String one) {
|
||||
this.one = one;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public TEvent getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void setEvent(TEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public List<TEventMany> getMany() {
|
||||
return many;
|
||||
}
|
||||
|
||||
public void setMany(List<TEventMany> many) {
|
||||
this.many = many;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.avaje.tests.model.tevent;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestAssocOneNullTraverse extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
TEvent event = new TEvent("event");
|
||||
Ebean.save(event);
|
||||
|
||||
Ebean.find(TEvent.class)
|
||||
.fetch("one.many")
|
||||
.findList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user