• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OneToMany design issue in JPA

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic