This question is a follow up the question found here: ActiveAndroid Many-to-many relationship
I have been working on querying my join table following along with the best answer from the above question, but I can't get it to work with my specific project.
I am building a twitter-clone project as a practice project. I want to have a Many to Many relationship between tweets and hashtags.
Here is my join table:
@Table(name = "tag_tweets", id = "_id")
public class TagTweet extends Model {
@Column(name = "Tweet")
public Tweet mTweet;
@Column(name = "Tag")
public Tag mTag;
public TagTweet() {
super();
}
public TagTweet(Tag tag, Tweet tweet) {
super();
mTweet = tweet;
mTag = tag;
}
}
I built my query in my Tag
class:
public List<Tweet> getTweets() {
List<Tweet> tweets = new Select()
.from(Tweet.class)
.innerJoin(TagTweet.class)
.on("tag_tweets.Tweet = Tweet")
.where("tag_tweets.Tag = ?", this.getId())
.execute();
return tweets;
}
This is populating tweets
with every tweet in my database. I only want the tweets associated to the tag that I am calling the method on.
I am assuming my query isn't being constructed properly.