I have an application that uses Spring and Hibernate. There are some views in my database that I need to load in some objects. Therefore, I am trying to fulfill my own request and load the class with the data obtained from the view:
//In my DAO class (@Repository) public List<MyClass> findMyEntities(){ Query query = em.createNativeQuery("SELECT * FROM V_myView", MyClass.class); return query.getResultList(); }
and MyClass has the same fields as the column names of the view.
The problem is that Hibernate cannot recognize MyClass because it is not an entity (it is not annotated with @Entity)
org.hibernate.MappingException: unknown object
If I put MyClass as an entity, the system will attempt to create / update a table for this object, because I configured it:
<property name="hibernate.hbm2ddl.auto" value="update"/>
So, I get into the following questions:
- Is it possible to disable "hibernate.hbm2ddl.auto" for only one object?
- Is there a way to load data from a view into a class without an entity?
- If not, what would be the best way in my case for loading data from a view into a class in sleep mode?
thanks
source share