Failing testcase with lazy fetch

For some reason, all entities with an id starting with _ fails when
lazy-fetching due to sort not being properly renamed.
This commit is contained in:
Tobias
2018-07-11 15:52:56 +02:00
parent 59537227b6
commit df892f4509
3 changed files with 91 additions and 0 deletions
@@ -0,0 +1,36 @@
package org.tests.model.lazywithid;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
@Entity
public class Looney {
@Id
public Long id;
@ManyToOne
private Tune tune;
private String name;
public Looney(final String name) {
this.name = name;
}
public Tune getTune() {
return tune;
}
public void setTune(final Tune tune) {
this.tune = tune;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
}
@@ -0,0 +1,26 @@
package org.tests.model.lazywithid;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
public class TestColumnIdName extends BaseTestCase {
@Test
public void test() {
Tune tune = new Tune();
tune.getLoonies().add(new Looney("Taz"));
Ebean.save(tune);
final List<Tune> fetchedCollection = Ebean.find(Tune.class).findList();
assertEquals(1, fetchedCollection.size());
assertEquals(1, fetchedCollection.get(0).getLoonies().size());
assertEquals("Taz", fetchedCollection.get(0).getLoonies().get(0).getName());
}
}
@@ -0,0 +1,29 @@
package org.tests.model.lazywithid;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import io.ebean.common.BeanList;
@Entity
public class Tune {
@Id
@Column(name = "id")
public Long _id;
@OneToMany(cascade = CascadeType.ALL)
private List<Looney> loonies = new BeanList<>();
public List<Looney> getLoonies() {
return loonies;
}
public void setLoonies(final List<Looney> loonies) {
this.loonies = loonies;
}
}