• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OneToMany design issue in JPA

 
David Freed
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to retrieve tweets by search keywords and save them in MySQL:

keyword table : id, keyword, tweet_id
tweet table: tweet_id,....

I only need bidirectional relation, in the class search Keyword I would like to retrieve all the corresponding tweets.

Should search Keyword entity have ManyToOne or OneToMany?

If ManyToOne on the search Keyword Entity, then how to retreiw the tweet resutls of a search Keyword? like this?





Thank you so much for your advices, I really want to understand these relationships. I'm completely confused and tired now.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Freed wrote:Thank you so much for your advices, I really want to understand these relationships. I'm completely confused and tired now.

When I'm in doubt, I always have a look at the Java Persistence Wikibook. It's really an excellent resource with tons of example mappings (both with annotation and xml).

Hope it helps!
Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic