join query for two tables in hibernate

hibernate

50 просмотра

1 ответ

I need an InnerJoin Query in HCQL for following native SQL query:

SELECT * FROM user INNER JOIN registered_users 
WHERE user.id=registered_users.user_id;

I need the result as list of user objects.

Can anyone help me?

Автор: Dinesh R Источник Размещён: 08.11.2019 11:12

Ответы (1)


0 плюса

You can use HQL like this :

SELECT U FROM User U INNER JOIN U.registeredUsers RU;

Or you can use native sql like this :

SELECT U.* FROM user U INNER JOIN registered_users RU WHERE U.id=RU.user_id;

I will prefer you to use HQL.

Автор: akash777.sharma Размещён: 21.08.2016 07:02
Вопросы из категории :
32x32