Announcement Announcement Module
Collapse
No announcement yet.
Please help with 'sessionFactory' or 'hibernateTemplate' is required Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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).

      Comment

      Working...
      X