I am trying to create a named query which joins a two tables based on an id. I am getting a HibernateException saying "errors in named queries: Users.getAllUsers
the Users bean has a private Set image variable. The UserImages bean is mapped to a table with the images for all the users. This is my named query.
@NamedQueries ({
@NamedQuery(name = "Users.getUserImage",
query("from Users as users INNER JOIN fetch users.image as image WHERE users.userId = image.userId" AND users.userId =: passedId)
})
I pass in the variable one as the passedId argument in the named query.
I am pretty new to hibernate but I was told to use the fetch command for this since I have a set within the User bean which holds a bunch of UserImage bean objects. Anyone see why this would not work? The actual SQL query that I am basing this off of which works in my sql editor is
SELECT * FROM users as u WHERE INNER JOIN user_images as images ON users.userId = images.userId AND users.userId = 1;