richardgundersen
Feb 11th, 2009, 07:28 AM
Hi
I spent a while trying to get the jee:jndi-lookup definition working (Hibernate EntityManager on Tomcat) without success (it seemed like the flashy way to do things).
<jee:jndi-lookup id="entityManagerFactory" jndi-name="java:comp/env/jdbc/myDs"/>
Then I realised I could do the same with JndiObjectFactoryBean, and it works fine.
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/myDs"/>
</bean>
myDs is configured in Tomcat's server.xml like so
<Context distributable="true" path="/BulkUploader" reloadable="true">
<Resource name="jdbc/myDs"
auth="Container"
type="javax.sql.DataSource"
username="username"
password="password"
driverClassName="oracle.jdbc.OracleDriver"
url="...myUrl..."
maxActive="8"
maxIdle="4"/>
</Context>
As I don't have a great understanding of how JPA, Spring, transactions etc all fit together, I'm wondering if my simpler approach comes at a cost (performance, transaction support etc etc).
It all seems to be working, but would appreciate any ideas/thoughts :)
Richard
I spent a while trying to get the jee:jndi-lookup definition working (Hibernate EntityManager on Tomcat) without success (it seemed like the flashy way to do things).
<jee:jndi-lookup id="entityManagerFactory" jndi-name="java:comp/env/jdbc/myDs"/>
Then I realised I could do the same with JndiObjectFactoryBean, and it works fine.
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/myDs"/>
</bean>
myDs is configured in Tomcat's server.xml like so
<Context distributable="true" path="/BulkUploader" reloadable="true">
<Resource name="jdbc/myDs"
auth="Container"
type="javax.sql.DataSource"
username="username"
password="password"
driverClassName="oracle.jdbc.OracleDriver"
url="...myUrl..."
maxActive="8"
maxIdle="4"/>
</Context>
As I don't have a great understanding of how JPA, Spring, transactions etc all fit together, I'm wondering if my simpler approach comes at a cost (performance, transaction support etc etc).
It all seems to be working, but would appreciate any ideas/thoughts :)
Richard