There is something I don't understand : Is Hibernate a DB manager and not only ORM? My question: I have SpringBootApplication and use hibernate for connection to database and ORM aspect. In my mind, connection to DB is continuous. On another hand, I want a puncual on-demand connection to an access DB, so I used simple java.sql.* library :
Class.forName("org.hsqldb.jdbcDriver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:ucanaccess://myDB.mdb", login, password);
This works but in order to not map manually each result query to a domain object, I would like to use hibernate to do :
getCurrentSession()
.createSQLQuery( "select e.id as id,e.first_name as firstName,e.password as password from xxxxxx")
.addScalar("id",StandardBasicTypes.INTEGER )
.addScalar("firstName",StandardBasicTypes.STRING )
.addScalar("password",StandardBasicTypes.STRING )
.setResultTransformer(Transformers.aliasToBean(Employee.class))
.list();
in order to have query result automatically bind to DOmain object.
BUT this is only available for hibernate library, not java.sql (or I didn't find). SO should I have a second hibernate connection but not permanent so not configured in application.properties/hibernate.properties and so not managed by Spring (in order to have punctual connection)? In my mind, I would like to do something identical to java.sql previous example but with hibernate.
You will understand that I think I miss something about hibernate philosophy.
Thank you.