Hello, all!
Sounds easy but not appear so in practice...
Let's say I have entity class User with @id Long id; and @Column String name;.
And I have other table with user profile data.
The columns: user_id, name, value.
One of profile names is 'NICKNAME'.
So to store nickname Brutt of user with id 1 I create profile record:
1, "NICKNAME", "Brutt".
Now what if I need to show some users with nicknames ordered by nickname?
I created a view as
SELECT u.*, p.value as nickname FROM u users, p profiles WHERE p.user_id = u.id AND p.name = 'NICKNAME'
class UserNicknameView extends User {