-->
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.  [ 9 posts ] 
Author Message
 Post subject: Generic Dao Problem getHibernateTemplate() is returning null
PostPosted: Thu Mar 05, 2009 3:23 am 
Beginner
Beginner

Joined: Fri Feb 20, 2009 2:19 am
Posts: 33
here is my hibernate.cfg.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
    <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
    <property name="hibernate.connection.url">jdbc:oracle:thin:@192.1.200.32:1521:orcl</property>
    <property name="hibernate.connection.username">****</property>
    <property name="hibernate.connection.password">****</property>
      <property name="current_session_context_class">thread</property>
      <mapping class="javaapplication42.Employee"/>
  </session-factory>
</hibernate-configuration>


Employee.java
Code:
package javaapplication42;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "EMPLOYEE")
public class Employee implements Serializable {
   public Employee() {

   }
   @Id
   @Column(name = "id")
   Integer id;

    public Employee(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

   @Column(name = "name")
   String name;

   public Integer getId() {
      return id;
   }

   public void setId(Integer id) {
      this.id = id;
   }

   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }

}


EmployeeImpl.java
Code:
package javaapplication42;

public class EmployeeImpl extends BaseAbstractDao<Employee> implements EmployeeDao{

    /**
     * @param args the command line arguments
     */
    @Override
    public void saveEmployee(Employee employee) {
        System.out.println("in saveEmployee");
       super.saveOrUpdateEntity(employee);
    }
   public EmployeeImpl(){
       System.out.println("in EmployeeImpl");
        saveEmployee(new Employee(new Integer(1),"abc"));
    }
}

GenericDao.java
Code:
package javaapplication42;

public interface GenericDao  <T> {
public void saveOrUpdateEntity(T entity);

}

EmployeeDao.java
Code:
package javaapplication42;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/



/**
*
* @author jjoshi
*/
public interface EmployeeDao extends GenericDao<Employee> {
     public void saveEmployee(Employee employee);

}

BaseAbstractDao.java
Code:
package javaapplication42;




import java.lang.reflect.ParameterizedType;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public abstract class BaseAbstractDao<EntityType> extends HibernateDaoSupport implements GenericDao<EntityType> {
     private Class<EntityType> persistentClass;
     @SuppressWarnings("unchecked")
    public BaseAbstractDao() {
        super();
        this.persistentClass = (Class<EntityType>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
         System.out.println("in BAseAbstractDao");
    }
     @Override
    public void saveOrUpdateEntity(EntityType entity) {

         System.out.println("output = "+getHibernateTemplate());
         System.out.println("in saveOrUpdate");
    }
}

HibernateUtil.java
Code:
package javaapplication42;



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil {

    private Statement st;
    private static final SessionFactory sessionFactory;


    static {

        try {
            // Create the SessionFactory from hibernate.cfg.xml
            sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();

        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public HibernateUtil() {
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection con = DriverManager.getConnection("jdbc:oracle:thin:@192.1.200.32:1521:orcl", "student", "student");
            st = con.createStatement();
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    public ResultSet executeSQLCommand(String sql) throws Exception {

       
        return (st.executeQuery(sql));
    }
}


Main.java

Code:
package javaapplication42;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
public class main {
    public static void main(String[] args) {
    SessionFactory session = HibernateUtil.getSessionFactory();
     Session sess = session.getCurrentSession();
        /** Starting the Transaction */
        Transaction tx = sess.beginTransaction();
        System.out.println("Transaction is "  +tx );
        System.out.println("Session is  "  +sess );
        EmployeeImpl ob= new EmployeeImpl();

    }

}
theException i am getting is
run:
5 Mar, 2009 12:39:30 PM org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.1.GA
5 Mar, 2009 12:39:30 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
5 Mar, 2009 12:39:30 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
5 Mar, 2009 12:39:30 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
5 Mar, 2009 12:39:30 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
5 Mar, 2009 12:39:30 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
5 Mar, 2009 12:39:30 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
5 Mar, 2009 12:39:30 PM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
5 Mar, 2009 12:39:30 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: javaapplication42.Employee
5 Mar, 2009 12:39:30 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity javaapplication42.Employee on table EMPLOYEE
5 Mar, 2009 12:39:31 PM org.hibernate.cfg.AnnotationConfiguration secondPassCompile
INFO: Hibernate Validator not found: ignoring
5 Mar, 2009 12:39:31 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
5 Mar, 2009 12:39:31 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
5 Mar, 2009 12:39:31 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
5 Mar, 2009 12:39:31 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: oracle.jdbc.OracleDriver at URL: jdbc:oracle:thin:@192.1.200.32:1521:orcl
5 Mar, 2009 12:39:31 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=student, password=****}
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: Oracle JDBC driver, version: 10.2.0.1.0XE
5 Mar, 2009 12:39:33 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.OracleDialect
5 Mar, 2009 12:39:33 PM org.hibernate.dialect.Oracle9Dialect <init>
WARNING: The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead
5 Mar, 2009 12:39:33 PM org.hibernate.dialect.OracleDialect <init>
WARNING: The OracleDialect dialect has been deprecated; use Oracle8iDialect instead
5 Mar, 2009 12:39:33 PM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
5 Mar, 2009 12:39:33 PM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
5 Mar, 2009 12:39:33 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
5 Mar, 2009 12:39:33 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
5 Mar, 2009 12:39:36 PM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
5 Mar, 2009 12:39:36 PM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Transaction is org.hibernate.transaction.JDBCTransaction@1976011
Session is SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
in BAseAbstractDao
in EmployeeImpl
in saveEmployee
output = null
in saveOrUpdate
BUILD SUCCESSFUL (total time: 8 seconds)


getHibernateTemplate() is returning null
how to overcome it???




Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 05, 2009 4:40 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
This question would probably be better answered on the spring forums.

However, it looks like you have not configured your app correctly. I don't see the sessionFactory being given to your dao anywhere. You should look at the spring documentation.

Even better you might want to try and make this work with out spring first just so you can better understand how hibernate works.

_________________
Please rate my replies as I need points for all of my questions also.


Top
 Profile  
 
 Post subject: Solved
PostPosted: Fri Mar 06, 2009 12:38 am 
Beginner
Beginner

Joined: Fri Feb 20, 2009 2:19 am
Posts: 33
The problem has been solved ,
my mistake was "i was not linking session with hibernate template"

the following code has solved my problem

Code:
HibernateTemplate ob= new HibernateTemplate(HibernateUtil.getSessionFactory(),true);
ob.save(entity);
         System.out.println("Saved . . .");
         ob.getSessionFactory().getCurrentSession().getTransaction().commit();
         ob.getSessionFactory().close();


I get the work done ...
m i doing any wrong thing?
i mean is there any better way to do it????


Top
 Profile  
 
 Post subject: Re: Solved
PostPosted: Fri Mar 06, 2009 3:32 am 
Beginner
Beginner

Joined: Wed Nov 19, 2008 8:25 am
Posts: 46
Location: Saint Petersburg, Russian Federation
void_void wrote:
...
m i doing any wrong thing?
i mean is there any better way to do it????


  1. Remove <property name="current_session_context_class">thread</property> from the hibernate config. Spring uses its own implementation of the current context in order to embed hibernate transactions to spring transactions infrastructure;
  2. Don't create HibernateTemplate if you already use HibernateDaoSupport. Feel free to check spring reference for more details about that;
  3. Correctly setup spring transactions in order for them to be applied declaratively;


Top
 Profile  
 
 Post subject: now i want to integrate this DAO in Spring
PostPosted: Mon Mar 09, 2009 12:49 am 
Beginner
Beginner

Joined: Fri Feb 20, 2009 2:19 am
Posts: 33
now i want to integrate this DAO in Spring's bean...
i mean my Spring's service bean should be able to call this DAO's methods...
how can i inject hibernate into Spring...


rest of the code is given above @ the starting of this thread...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 10, 2009 1:09 am 
Beginner
Beginner

Joined: Fri Feb 20, 2009 2:19 am
Posts: 33
this is my DAOContext.xml file

Code:
<?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:context="http://www.springframework.org/schema/context"
       xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


    <bean id="medConfigProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location">
            <value>classpath:med.database.properties</value>
        </property>
        <property name="ignoreUnresolvablePlaceholders" value="true" />
    </bean>

    <bean id="hibernateConfigProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="location">
            <value>classpath:hibernate.properties</value>
        </property>
    </bean>


    <bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close"
   p:driverType="${med.connection.driverClassName}" p:URL="${med.connection.url}"
   p:user="${med.connection.username}" p:password="${med.connection.password}"/>


    <bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" />
   
    <bean  id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
    p:dataSource-ref="dataSource" p:lobHandler-ref="lobHandler">
        <property name="annotatedClasses">
            <list>
                <value> org.argus.webpanditji.GenericDAO.Employee</value>
            </list>

        </property>
        <property name="schemaUpdate">
            <value>false</value>
        </property>
        <property name="hibernateProperties" ref="hibernateConfigProperties" />
    </bean>



<!--
    Instruct Spring to perform automatic transaction management on annotated classes.
    The SimpleJdbcClinic implementation declares @Transactional annotations.
    "proxy-target-class" is set because of SimpleJdbcClinic's @ManagedOperation usage.
    -->
    <tx:annotation-driven transaction-manager="transactionManager" />

    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <constructor-arg>
            <ref bean="sessionFactory"/>
        </constructor-arg>
    </bean>

    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"  p:sessionFactory-ref="sessionFactory">

    </bean>











   

    <bean id="EI" class="org.argus.webpanditji.GenericDAO.EmployeeImpl">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>


    <bean id="hw" class="org.argus.webpanditji.GenericDAO.HelloWorld"></bean>
 



   
   
   
  <!--
    Instruct Spring to perform automatic transaction management on annotated classes.
    The SimpleJdbcClinic implementation declares @Transactional annotations.
    "proxy-target-class" is set because of SimpleJdbcClinic's @ManagedOperation usage.
    -->
   
</beans>


Top
 Profile  
 
 Post subject: Excception i am getting
PostPosted: Tue Mar 10, 2009 1:10 am 
Beginner
Beginner

Joined: Fri Feb 20, 2009 2:19 am
Posts: 33
Code:
INFO: Initializing Mojarra (1.2_10-b01-FCS) for context '/JSFSpring'
WARNING: JSF1058: The resource referred to by to-view-id, 'success.jsp', for navigation from '/index.jsp', does not start with '/'.  This will be added for you, but it should be corrected.
WARNING: JSF1058: The resource referred to by to-view-id, 'fail.jsp', for navigation from '/index.jsp', does not start with '/'.  This will be added for you, but it should be corrected.
INFO: PWC1412: WebModule[/JSFSpring] ServletContext.log():Initializing Spring root WebApplicationContext
SEVERE: log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: WebModule[/JSFSpring]PWC1275: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.transaction.interceptor.TransactionInterceptor] while setting bean property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [DAOContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [DAOContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [DAOContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [DAOContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [DAOContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [DAOContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [DAOContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
Caused by: java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
        at org.hibernate.bytecode.javassist.BytecodeProviderImpl.getProxyFactoryFactory(BytecodeProviderImpl.java:49)
        at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactoryInternal(PojoEntityTuplizer.java:203)
        at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTupliz


Top
 Profile  
 
 Post subject: Re: Generic Dao Problem getHibernateTemplate() is returning null
PostPosted: Mon Apr 23, 2012 7:35 am 
Newbie

Joined: Mon Apr 23, 2012 7:27 am
Posts: 2
I am also facing the same issue.I have declared everything in beans.xml.here is my code

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="annotatedClasses">
<list>

<value>com.infosys.persistence.Country</value>

<value>com.infosys.persistence.XMLReader</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>
<!-- <prop key="hibernate.connection.pool_size">100</prop> -->
<!-- db connection pool c3p0 -->
<prop key="hibernate.c3p0.min_size">10</prop>
<prop key="hibernate.c3p0.max_size">100</prop>
<prop key="hibernate.c3p0.timeout">100</prop>
<prop key="hibernate.c3p0.max_statements">100</prop>
<prop key="hibernate.c3p0.idle_test_period">200</prop>
<!-- <prop key="hibernate.c3p0.acquire_increment">${hibernate.c3p0.acquire_increment}</prop> -->
</props>
</property>
<property name="dataSource">
<!--
<ref bean="dataSource" />
-->

<ref bean="c3p0DataSource" />

</property>
</bean>

<!--
This will automatically locate any and all property files you have
within your classpath, provided they fall under the META-INF/spring
directory. The located property files are parsed and their values can
then be used within application context files in the form of
${propertyKey}.
<context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>
-->

<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value=""/>
<property name="username" value=""/>
<property name="password" value=""/>
</bean>

<bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="jdbc:oracle:thin:@chdsez134066d:1521:XE" />
<property name="user" value="toyota1" />
<property name="password" value="cocobino" />
<property name="initialPoolSize" value="5" />
<property name="maxPoolSize" value="100" />
<property name="minPoolSize" value="3" />
<property name="acquireIncrement" value="1" />
</bean>


<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<constructor-arg>
<ref bean="sessionFactory"/>
</constructor-arg>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>



<bean id="countryDao" class="com.infosys.persistence.CountryDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="sAXBbuilder" class="org.jdom.input.SAXBuilder">
</bean>

My gethibernatetemplate() is coming null.Kindly help me out


Top
 Profile  
 
 Post subject: Re: Generic Dao Problem getHibernateTemplate() is returning null
PostPosted: Mon Apr 23, 2012 8:26 am 
Newbie

Joined: Mon Apr 23, 2012 7:27 am
Posts: 2
can anybody resolve my issue that what needs to be added in my beans.xml so that my getHibernateTemplate() may not return null....


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.