Sorry, but I am repeating my question, because the error has not been rectified.
I made service and dao layers as interfaces. I didn't made any hibernate cfg xml file, but I wrote all the hibernate configurations under application context.
this is only a test program.
When I am trying to get the username and and password from entity class, the session factory points to null always. If you need more specific code just mention it.
application Context:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
    http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
    <context:component-scan base-package="com.company"/>
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>/WEB-INF/*.properties</value>
        </property>
    </bean>
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 
        destroy-method="close" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.databaseurl}" 
        p:username="${jdbc.username}" p:password="${jdbc.password}">
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="packagesToScan" value="com.company.entity"/>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${jdbc.Dialect}</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.internal.NoCachingRegionFactory</prop>
            </props>
        </property>
        <property name="entityInterceptor">
            <bean class="com.company.interceptor.AuditInterceptor"/>
        </property>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
      <property name="sessionFactory" ref="sessionFactory"/>  
    </bean>
   <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
    <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
    <property name="transactionManager" ref="transactionManager"/>
    <property name="transactionAttributes">
        <props>
            <prop key="create*">PROPAGATION_REQUIRED</prop>
            <prop key="save*">PROPAGATION_REQUIRED</prop>
            <prop key="delete*">PROPAGATION_REQUIRED</prop>
            <prop key="update*">PROPAGATION_REQUIRED</prop>
            <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
        </props>
    </property>            
    </bean>
    <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        <property name="beanNames">
            <value>*DaoImpl</value>
        </property>
       <property name="interceptorNames">
           <value>transactionInterceptor</value>
       </property>
    </bean>
    <import resource="spring-security.xml"/>
</beans>
User Dao Impl:
 @Repository
 public class UserDaoImpl extends AbstractDao  implements UserDao {
 public boolean test(){
    int id=1;
    boolean result;
    try{
        User user=null;
        user=(User) this.sessionFactory.getCurrentSession().get(User.class,id);
        System.out.println(user.getUsername());
        System.out.println(user.getPassword());
        result=true;
        return result;
     }catch(NullPointerException n){
         System.out.println("inside null pointer exception handler");
         n.printStackTrace();
         result=false;
         return result;
     }
UserServive:
@Service
public class UserServiceImpl implements UserService {
    public boolean test(){
        UserDao userDao=new UserDaoImpl();
        return userDao.test();
    }
}
UserController:
 @Controller
 public class LoginController {
 private Logger logger;
 @Autowired
 UserService userService;
 @RequestMapping(value="/login.do",method=RequestMethod.POST)
 public String login(HttpServletRequest request,HttpServletResponse response){
     boolean result=userService.test();
     if(result=true){
          return "profile";
     }else{
          return "home";
     }
}
Abstract Dao:
public class AbstractDao{
    @Autowired
    protected SessionFactory sessionFactory;
}
 
    