mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor FetchConfig
This commit is contained in:
@@ -28,7 +28,7 @@ public class TestQueryJoin extends BaseTestCase {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class).select("status")
|
||||
// .join("details","+query(10)")
|
||||
.fetch("customer", "+lazy(10) name, status").fetch("customer.contacts").order().asc("id");
|
||||
.fetch("customer", "+lazy(10), name, status").fetch("customer.contacts").order().asc("id");
|
||||
// .join("customer.billingAddress");
|
||||
|
||||
List<Order> list = query.findList();
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.tests.model.interfaces;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class SelfManyMany {
|
||||
|
||||
@Id
|
||||
private long id;
|
||||
|
||||
private final String name;
|
||||
|
||||
@ManyToMany
|
||||
// requires explicit @JoinTable
|
||||
@JoinTable(name = "self_many_bridge",
|
||||
joinColumns = @JoinColumn(name = "self_1_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "self_2_id"))
|
||||
private List<SelfManyMany> related;
|
||||
|
||||
public SelfManyMany(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<SelfManyMany> getRelated() {
|
||||
return related;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.tests.model.interfaces;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestSelfMany extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void self_manyToMany() {
|
||||
|
||||
SelfManyMany m = new SelfManyMany("1");
|
||||
DB.save(m);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user