Reputation: 21
I have a project running live for couple of years and it uses plain JDBC.
Now I have to implement a small module for which I am considering Hibernate. I configured Hibernate (hibernate-cfg.xml) and it's up and running.
So I have DB properties defined in two places oracle-ds.xml and hibernate-cfg.xml
Upvotes: 2
Views: 1076
Reputation: 570355
Is that OK to mix jdbc, hibernate in a single application, if not what are the issues?
It's doable but you need to take some precautions:
Do I need to configure "connection pool" in hibernate configuration and also in oracle-ds.xml
I would configure Hibernate to use the app server connection pool (see the Hibernate Datasource Properties).
I thought of configuring hibernate using JNDI but that needs mbean, HAR thats extra work and this new module is going to be used rarely. OR Should I make it as an jboss service so that connection pooling is handled by container?
You don't need to use a JBoss service or to use a HAR to use connection pooliong, see the above link. And I wouldn't bother with that for now, this is very low priority stuff in my opinion. First, bootstrap a first prototype, see how it fit with your existing code, what needs to be changed, etc.
Upvotes: 1
Reputation: 6317
We've mixed the two in the same application with no problems. I set the server to manage the connection pool so they end up getting shared between the JDBC code and hibernate code.
One thing you do have to keep in mind is hibernate caches the data in memory, so if you change a hibernate table directly, the application will still keep seeing the old data that's in the cache. If you turn off the cache, it takes a big performance hit. It saves you coding but you lose a lot in flexibility. It's difficult to integrate with other applications through the database and do things like replication between sites.
Upvotes: 0