-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: HibernateTemplate Using Spring Declarative Connection
PostPosted: Wed Apr 21, 2010 5:55 am 
Newbie

Joined: Wed Apr 21, 2010 5:49 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.