0

I'm working on a program that receives tweets from the twitterstream, and stores them in the DB.

There is a Keyword Model, and a Tweet Model

The keyword model has a manytomany of tweets, ex.

@ManyToMany
List<Tweets> tweets;

I want to search tweets, and return only the ones that are assigned to that keyword. In vanilla SQL similar to:

SELECT * FROM tweet t, keyword k, keyword_tweet kt where t.id=kt.tweet_id and k.id=kt.keyword_id

Any idea how to do this in Play! using ebean?

Each Tweet has an ID, each keyword has an ID, Play automatically created another table "keyword_tweet" for the @ManyToMany association.

Jordan H
  • 181
  • 1
  • 2
  • 11

1 Answers1

0

You can do something like this:

public List<Tweets> findTweets(Tweet t) {
     return Tweets.find
            .where()
            .eq("tweets.id", t.id)
            .findList();
}

Same as mentioned in Here

Community
  • 1
  • 1
mayurc
  • 267
  • 4
  • 13