-
1. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
qwertywin Mar 10, 2009 3:28 AM (in response to knice147)I believe you can no longer do it from hibernate, as the one of the main purposes was to not expose you to JDBC, same goes for JPA
you can always just executre native SQL queries I believe you can use entityManager.createNativeQuery();
-
2. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
knice147 Mar 10, 2009 3:32 AM (in response to knice147)I just want JPA or hibernate or allocate manage the database connection and I will use JDBC to do the rest. Is that possible. I saw a few examples using session.getConnection() to get the Connection object? R u saying that this is no longer possible? Is there a way to gain access to the database Connection object in this fashion?
-
3. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
swd847 Mar 10, 2009 3:32 AM (in response to knice147)Are you in a EJB3 environment? If so you can inject a datasource into an EJB using @Resource.
If not depending on the underlying persistence provider there would probably be a non-portable way of doing this, similar to the hibernate way.
-
4. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
knice147 Mar 10, 2009 3:35 AM (in response to knice147)In a nutshell, I am trying to run stored procedures and it seems like JPA and hibernate are not very friendly in this fashion. So I created a utility class to handle the actual stored procedure interaction. I just need to connect the database Connection object.
-
5. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
swd847 Mar 10, 2009 3:35 AM (in response to knice147)Why would you possibly want to do this? This is the job of your containers connection pool.
-
6. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
knice147 Mar 10, 2009 3:37 AM (in response to knice147)There is no EJB 3 container. If hibernate will accomplish this task I guess that will be sufficient. Do you have any examples on getting the Connection object from the hibernate Session?
-
7. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
knice147 Mar 10, 2009 3:39 AM (in response to knice147)Do you mean Container as in Tomcat or EJB?
Stuart Douglas wrote on Mar 10, 2009 03:35:
Why would you possibly want to do this? This is the job of your containers connection pool.Click HELP for text formatting instructions. Then edit this text and check the preview.
-
8. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
swd847 Mar 10, 2009 3:44 AM (in response to knice147)You need to set up the the tomcat connection pool. Have a look here for instructions, you are interested in the bit about JDBC data sources.
-
9. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
knice147 Mar 10, 2009 3:51 AM (in response to knice147)How would I use this utility class with SEAM. My idea is to have this utility class actually handle the population of the entities. As well as other procedure-related operations. Now would I still need to declare an EntityManager in the ActionClass or would this be a mute point?
Stuart Douglas wrote on Mar 10, 2009 03:44:
You need to set up the the tomcat connection pool. Have a look here for instructions, you are interested in the bit about JDBC data sources.Click HELP for text formatting instructions. Then edit this text and check the preview.
-
10. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
knice147 Mar 10, 2009 3:55 AM (in response to knice147)Also, I figured this could be a handoff or responsibilities or sorts. Once the connection was pulled from JPA or hibernate it would handoff the database operation to the utility class.
Anthony Taylor wrote on Mar 10, 2009 03:51:
How would I use this utility class with SEAM. My idea is to have this utility class actually handle the population of the entities. As well as other procedure-related operations. Now would I still need to declare an EntityManager in the ActionClass or would this be a mute point?
Stuart Douglas wrote on Mar 10, 2009 03:44:
You need to set up the the tomcat connection pool. Have a look here for instructions, you are interested in the bit about JDBC data sources.
Click HELP for text formatting instructions. Then edit this text and check the preview.Click HELP for text formatting instructions. Then edit this text and check the preview.
-
11. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
swd847 Mar 10, 2009 4:39 AM (in response to knice147)When did entities come into it? To use entities you use hibernate or another JPA provider, not raw JDBC.
-
12. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
knice147 Mar 10, 2009 5:02 AM (in response to knice147)How do you populate them with information from the database when using stored procedures?
Stuart Douglas wrote on Mar 10, 2009 04:39:
When did entities come into it? To use entities you use hibernate or another JPA provider, not raw JDBC.Click HELP for text formatting instructions. Then edit this text and check the preview.
-
13. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
swd847 Mar 10, 2009 5:07 AM (in response to knice147)If you are using hibernate you can use @SQLInsert and friends, documented here
-
14. Re: Is it possible to get a database connection with JPA without using hibnernate as well?
knice147 Mar 10, 2009 7:14 AM (in response to knice147)what if you are using stored procedures?
Stuart Douglas wrote on Mar 10, 2009 05:07:
If you are using hibernate you can use @SQLInsert and friends, documented hereClick HELP for text formatting instructions. Then edit this text and check the preview.