Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6948637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:50:56+00:00 2026-05-27T13:50:56+00:00

How can I join two tables by using java play framework and jpa, I

  • 0

How can I join two tables by using java play framework and jpa, I really have a hardtime converting my MySQL query to jpa query.

Here is the MySQL query that I used in my old Java code:

SELECT * FROM tbl_majors
INNER JOIN tbl_lookup_user_major
ON tbl_majors.id=tbl_lookup_user_major.majorId
WHERE tbl_lookup_user_major.userId=12

//Table 1:

@Entity
@Table(name="tbl_majors")
public class Major extends Model {
    public Major(){

    }
    @Column(name="major_name")
    private String name;
    @Column(name="major_desc")
    private String description;
}

//Table 2

@Entity
@Table(name="tbl_lookup_user_major")
public class LookupUserMajor extends Model {
    public LookupUserMajor(){

    }
    private int majorId;
    private int userId;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:50:57+00:00Added an answer on May 27, 2026 at 1:50 pm

    Dont know if I get the exact point here, but in the tutorial blog “YABE”, this kind of join table is used and created automatically by Play :

    http://www.playframework.org/documentation/1.2.4/guide6#tagging

    The many-to-many relation is described in the Model (between “Post” and “Tag” here for the blog sample) :

    @ManyToMany(cascade=CascadeType.PERSIST)
    public Set<Tag> tags;
    
    public Post(User author, String title, String content) {
        ...
        this.tags = new TreeSet<Tag>();
        ...
        this.title = title;
        this.content = content;
        ...
    }
    

    The YAML for the Posts data is :

    Post(jeffPost):
        title:          The MVC application
        postedAt:       2009-06-06
        author:         jeff
        tags:           
                        - play
                        - architecture
                        - mvc
    

    After running the app, I check the database and the table “post_tag” is automatically created and all the links between the two tables are done (post_ids and tags_ids are filled).

    Retrieving data seems as easy as :

    "select distinct p from Post p join p.tags as t"
    

    Can someone confirm that ? Because new to Java and JPA and Play ^^

    If this is correct, it looks easier than managing the join table “manually”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can i join two tables using LINQ for NHibernate like I can do in
I have two tables that I join on the id-column, they look like: +-------+
I'm using RealURL on a site where I would like to join two tables
I am trying to query data from two tables into one tables using OUTER
So I have two tables in this simplified example: People and Houses. People can
I'm setting up a database using phpMyAdmin. I have two tables ( foo and
I have two tables in a MySQL database, courses and sessions. I'm trying to
I have two tables which I need to join. First Table: EFF_DATE RATE CURRENCY
I have two Entity (tables) - Employee & Project. An Employee can have multiple
I have two tables with identical fields, 35 identical fields. I know I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.