User declaration:
@Entity public class User { @Id @GeneratedValue private Integer id; ....
Pattern declaration:
<
What happens if you change your HQL query to from UserPattern where user.id = :user_id and pattern.id = :pattern_id?
from UserPattern where user.id = :user_id and pattern.id = :pattern_id
I think Hibernate is confusing objects and ID fields.