• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Fetching the posts of the profiles the user follows

 
shivang sarawagi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my db schema I have two tables

UserPublisher table : It contains info the number of user profiles the currently loggedIn user follows. A single user follows multiple profiles



Post table : It contains posts which the users post.



Now I want to fetch the posts of the user profiles which the current user follows.

I am using hibernate for object relational mapping.

Presently I am fetching the profiles which the user follows & then running the query on POST table for the list of user profiles.



What this be the best approach? I do have to fire two db queries in this scenario, I was hoping could this be achieved may be in one single query or some other way
 
Roel De Nijs
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivang sarawagi wrote:What this be the best approach? I do have to fire two db queries in this scenario, I was hoping could this be achieved may be in one single query or some other way

Probably using a join query. So you only need one single query.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic