0

Need Hibernate query to join 2 distinct tables . ex:

private class User
{
    private long userid;
    private String name;

    //stters and getters
}

And onother table as

private class UserProfile
{
    private long id;
    private String company;

    //setters and getters
}

Here userid and id are the same constraints.

Please help in this regards Thanks

Ruslan
  • 6,090
  • 1
  • 21
  • 36

1 Answers1

0

HQL uses entity names and entity property names. Never table or column names.

I suggest you read the documentation about HQL, and especially about joins and associations. http://docs.jboss.org/hibernate/core/4.3/manual/en-US/html/ch16.html#queryhql-joins

The query you need is:

select user.id, user.name, profile.id, profile.company from User as user
inner join user.UserProfile as profile
Nipuna Priyamal
  • 370
  • 2
  • 14