Hi i am using spring and hibernate .I tried to establish a jndi connection usign jndiObjectFactoryBean .I am using annotated classes.The applicationContext.xml file looks like this and i tried to establish a transaction management using Spring AOP.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/b ... ns-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/a ... op-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/t ... tx-2.5.xsd">
<bean id="customer1DataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/testDB1</value>
</property>
</bean>
<bean id="customer1SessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="customer1DataSource" />
</property>
<property name="annotatedClasses">
<list>
<value>com.kumaran.testing.UserDetailsDTO
</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLInnoDBDialect
</prop>
</props>
</property>
</bean>
<bean id="transactionManagerCustomer1"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="customer1DataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManagerCustomer1"
mode="proxy" />
<tx:advice id="txUserDetailsDTO" transaction-manager="transactionManagerCustomer1">
<tx:attributes>
<tx:method name="*" read-only="false" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="configService"
expression="execution(* com.kumaran.testing.TestDAO.*(..))" />
<aop:advisor advice-ref="txUserDetailsDTO" pointcut-ref="configService" />
</aop:config>
<bean id="userDetailsDao" class="com.kumaran.testing.TestDAO">
<property name="sessionFactory" ref="customer1SessionFactory" />
</bean>
</beans>
But when i tried like this in my DAO
public class TestDAO extends HibernateDaoSupport {
public void getDetails() {
UserDetailsDTO userDetailsDTO = new UserDetailsDTO();
userDetailsDTO.setName("Karthik");
userDetailsDTO.setDescription("Customer4");
getHibernateTemplate().save(userDetailsDTO);
}}
it throws NullPointerException.What i have to change in my code.Thanks in advance.
Regards
Logeswaran