Results 1 to 3 of 3

Thread: Please help with 'sessionFactory' or 'hibernateTemplate' is required

  1. #1

    Default Please help with 'sessionFactory' or 'hibernateTemplate' is required

    Folks,

    I am struggling with this error for a few hours now.I have put sessionFactory everywhere but this error does not go away.

    Here is my dao -
    Code:
    public class CsoProfileDaoImpl extends GenericDaoImpl<CsoProfile, Long> implements CsoProfileDao {
    	
    	
        public CsoProfileDaoImpl() {
            super(CsoProfile.class);
        }
    
        @Override
        public List<CsoProfile> findByCsoProfileName(String name) {
            return this.find("CsoProfile.findByCsoProfileName","%"+name+"%") ;
        }
    
    	
    	
    }
    I tried to put a SessionFactory variable in above class also but it did not make any difference.

    Here is applicationContext.xml -

    Code:
    <bean id="csoprofiledao" class="com.altcso.dao.CsoProfileDaoImpl">
            <property name="sessionFactory">
                <ref bean="sessionFactory" />
            </property>
        </bean>
        
        
        <bean id="genericdao" class="com.altcso.dao.GenericDaoImpl">
            <property name="sessionFactory">
                <ref bean="sessionFactory" />
            </property>
        </bean>
    Here is sessionfactory definition in applicationContext.xml itself -

    Code:
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
           
            <property name="configurationClass">
                <value>org.hibernate.cfg.AnnotationConfiguration</value>
            </property>
            <property name="annotatedClasses">
                <list>
                    <value>com.altcso.domain.TranslationContent</value>
        <value>com.cisco.altcso.domain.Customer</value>
        <value>com.cisco.altcso.domain.TranslationStatus</value>
        <value>com.cisco.altcso.domain.TransEngineProfileMap</value>
        <value>com.cisco.altcso.domain.Person</value>
        <value>com.cisco.altcso.domain.CsoProfile</value>
        <value>com.cisco.altcso.domain.CustomerCsoProfileMap</value>
        <value>com.cisco.altcso.domain.Users</value>
        </list>
        </property>
         <property name="hibernateProperties">
                <props>
                    <!--prop key="hibernate.hbm2ddl.auto">validate</prop -->
                    <prop key="hibernate.show_sql">false</prop>
                    <prop key="hibernate.dialect">
                        org.hibernate.dialect.Oracle9Dialect
                    </prop>
                    <prop key="hibernate.default_schema">altcso_admin</prop>
                     <prop key="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</prop>
          			<prop key="hibernate.connection.password">password</prop>
          			<prop key="hibernate.connection.url">jdbc:oracle:thin:@host:1521/URL</prop>
                    </props>
                    </property>
                    
    
    		</bean>
    Can someone please help?Thanks!!

  2. #2
    Join Date
    Aug 2006
    Posts
    113

    Default

    You did not post the actual error / stack track.

    I presume the class GenericDaoImpl has a setSessionFactory() method ?

    Are you sure your sessionFactory is being initialized ? is there any config error during startup ?

    There is also some discrpency between use of com.cisco.altcso... and com.altcso... packages (search your own post for those terms to see). I'm not sure what happens if you configure a SessionFactory but don't supply any valid entity classes to process.

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Judging from the message you don't set the sessionfactory on the dao. And judging from the message you are extending HibernateDaoSupport... In short, don't do that... Simply inject the sessionfactory and use it directly, don't use HibernateTemplate and/or HibernateDaoSupport (why, please use the forum search/google as I answered that question numerous times before).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •