I am using netbean and followed below steps to execute HQL query for table
- Did Reverse Engg
-
Generated mapping and POJO
Query query = session.createQuery("from MasUser as masUser where masUser.userName = '" + userName + "'"); masUser = (masUser) query.uniqueResult();
Now I am able to execute and got result.
Then I have created view for this table
CREATE VIEW test_view AS SELECT user_name, address FROM mas_user
Now I need to execute test_view in hibernate HQL.
Please provide the steps.
If you created the view in the database, the process of querying a view is exactly the same as working with a table. Simply create an entity (POJO) for the view, attach the mapping annotations and then create and execute a query. Repeat the same process that you did for your MasUser table.