| |

VerySource

 Forgot password?
 Register
Search
View: 770|Reply: 2

Ask a question about Spring's HibernateTemplate

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-4 18:50:01
| Show all posts |Read mode
It's weird, there is nothing wrong with the configuration, the bean always gets no value, and the log analysis is done.

Configuration file:

<? xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE beans PUBLIC "-// SPRING // DTD BEAN // EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
  <!-Hibernate SessionFactory->
  <bean id = "sessionFactory" class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <!-hibernate configFile Location->
    <property name = "configLocation">
      <value> classpath: hibernate.cfg.xml </ value>
    </ property>
    <!-References all OR mapping files.->
    <property name = "mappingDirectoryLocations">
      <list>
        <value> classpath: com / ziptimes / domain </ value>
      </ list>
    </ property>
  </ bean>

  <!-Pass the sessionfactory to HibernateTemplat->
  <bean id = "hibernateTemplate" class = "org.springframework.orm.hibernate3.HibernateTemplate">
    <property name = "sessionFactory">
      <ref bean = "sessionFactory" />
    </ property>
  </ bean>

  <!-Pass the HibernateTemplat to DAO->
  <bean id = "managerSupport" class = "com.ziptimes.manager.ManagerSupport">
    <property name = "hibernateTemplate">
      <ref bean = "hibernateTemplate" />
    </ property>
  </ bean>
</ beans>

bean:

public class ManagerSupport extends HibernateDaoSupport {
  public ManagerSupport () {
    log.debug ("Get the injected value:" + super.getHibernateTemplate ());
  }
}
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-20 17:45:01
| Show all posts
pls paste the error log here-
Reply

Use magic Report

0

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-30 07:15:01
| Show all posts
Look at the log, is it wrong?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list