java - Play Framework ManyToMany Association Access -
i have following 2 models in project:
@entity public class reports extends model{ @id @generatedvalue public int id; @manytomany(cascade = cascadetype.all) public list<tags> tags;
and
@entity public class tags extends model{ @id public string name; @manytomany(cascade = cascadetype.all) public reports reports;
since these 2 entities have @manytomany association, play! automatically creates table in postgresql database:
create table reports_tags ( reports_id integer not null, tags_name varchar(255) not null, constraint pk_reports_tags primary key (reports_id, tags_name)) ;
and here sample data of reports_tags
should like:
reports_id tags_name 1 pie 1 bar 1 line 3 plot 3 bar 4 scattered 4 plot
what i'm having problem want find reports tags_name = 'bar'
so "query" call, should reports
id
1 , 3.
using conventional way of
ebean.find(reports.class) .where() .eq("tags_name", "bar") .findlist()
won't work because there no such fields tags_name
in reports
model/table
i don't know code make query call since experience ebean little.
i have never worked play! framework, far understand part of contains jpa implementation. in jpa when querying should refer java entity field name, not column in table itself, i.e. query should
ebean.find(reports.class) .where() .eq("tags.name", "bar") .findlist()
you can refer examples in beginning of javadoc here
hope helps
Comments
Post a Comment