There is a request

SELECT * FROM [std].[dbo].[StudentProfile] A LEFT JOIN [std].[dbo].[User] U ON A.[StudentID] = U.[UserID] WHERE U.Usermail = 'a@a.com' 

I did not find or did not understand how to create the right criteria

 Criteria criteria = session.createCriteria(StudentProfile.class); criteria.createAlias("user", "User"); criteria.add(Restrictions.like("user.usermail", params.getEmail())); 

here on the 2nd line crashes. maybe who knows how to make correctly?

  • It is advisable to add a full stack trace error to the question. - v.ladynev

1 answer 1

If you do not specify the join type, then by default, the inner join .

You have in the request an exact match usermail .

You use alias with a small letter in user.usermail .

 Criteria criteria = session.createCriteria(StudentProfile.class); criteria.createAlias("user", "user", JoinType.LEFT_OUTER_JOIN); criteria.add(Restrictions.eq("user.usermail", params.getEmail())); 

In StudentProfile must be an association with User . For example, @OneToOne .

  • thank. I will try. - Vozmojno Furi