mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Can handle one to many & many to one relations in docstore only entities (#1158)
This commit is contained in:
committed by
Rob Bygrave
parent
1651d5e119
commit
bbe8abcc2e
@@ -0,0 +1,45 @@
|
||||
package org.tests.model.docstore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
import org.tests.model.basic.Customer;
|
||||
|
||||
import io.ebean.annotation.DocStore;
|
||||
|
||||
/**
|
||||
* Entity that will stored as JSON in database
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*
|
||||
*/
|
||||
@DocStore
|
||||
@DiscriminatorValue("CR")
|
||||
public class CustomerReport extends Report {
|
||||
|
||||
@OneToMany
|
||||
private List<Customer> friends;
|
||||
|
||||
@ManyToOne
|
||||
private Customer customer;
|
||||
|
||||
public void setCustomer(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setFriends(List<Customer> friends) {
|
||||
this.friends = friends;
|
||||
}
|
||||
|
||||
public List<Customer> getFriends() {
|
||||
return friends;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.tests.model.docstore;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
import org.tests.model.basic.Product;
|
||||
|
||||
import io.ebean.annotation.DocStore;
|
||||
|
||||
@DocStore
|
||||
@DiscriminatorValue("PR")
|
||||
public class ProductReport extends Report {
|
||||
|
||||
@ManyToOne
|
||||
private Product product;
|
||||
|
||||
public Product getProduct() {
|
||||
return product;
|
||||
}
|
||||
public void setProduct(Product product) {
|
||||
this.product = product;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.tests.model.docstore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
import io.ebean.annotation.DocStore;
|
||||
|
||||
@DocStore
|
||||
@Inheritance
|
||||
public class Report {
|
||||
private String title;
|
||||
|
||||
@OneToMany
|
||||
private List<Report> embeddedReports;
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public List<Report> getEmbeddedReports() {
|
||||
return embeddedReports;
|
||||
}
|
||||
|
||||
public void setEmbeddedReports(List<Report> embeddedReports) {
|
||||
this.embeddedReports = embeddedReports;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user