I created the entity classes of my database with NetBeans. I believe I know how to use EntityManager
(Class) db.createNamedQuery(String name);
but I don’t know where to put the statement (database link, login, password) so I learned how to query with
(JDBC4ResultSet) statement.executeQuery(String query);
but it returns the set which I don’t know how to transform into Entity class… something like
(Class) statement.execureQuery(String query).toEntity(Class);
would be nice. 😉
Ok, First you need to get an
EntityManagerfrom entity manager factory with yourpersistance unitname (which will be configured in persistance.xml). And then you create anEntityManager.This is just an heads up, You can google ‘jpa example’ to find out more working examples.