I have the following schema.
A(Aid, Aname)
B(Bid, Aid, Bname)
C(Cid, Bid, Cname)
B.Aid->A.Aid
C.Bid->B.Bid
I need to get the list of C.Cname to a given set of A.Aid s. I came up with this query.
SELECT C.Cname
FROM B,C
WHERE B.Bid = C.Bid AND B.Aid IN ('1','2','3')
I'm new to ebeans and I want to do this using ebeans. How can I do it? My models are as follows. I'm using mysql as my database.
class A
{
int Aid;
String Aname;
}
class B
{
int Bid;
A Aid;
String Bname;
}
class C
{
int Cid;
B Bid;
String Bname;
}
@Entity
class A {
@Id
int id;
String name;
}
class B {
@Id
int id;
@ManyToOne
A a;
String name;
}
@Entity
class C {
@Id
int id;
@ManyToOne
B b;
String name;
}
With correct Model, the next request can be work :
Ebean.find(C.class)
.fetch("b")
.fetch("b.a")
.where()
.in("b.a.id", [1, 2, 3])
.findList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With