[Html]
<? 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: aop = "http://www.springframework.org/schema/aop"
Xmlns: tx = "http://www.springframework.org/schema/tx"
Xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
Http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd ">
<! -- SessionFactory Transaction ************************************* ***** -->
<Bean id = "sessionFactory"
Class = "org. springframework. orm. hibernate3.LocalSessionFactoryBean">
<Property name = "configLocation"
Value = "classpath: hibernate. cfg. xml">
</Property>
</Bean>
--------------------------
</Beans>
<? 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: aop = "http://www.springframework.org/schema/aop"
Xmlns: tx = "http://www.springframework.org/schema/tx"
Xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
Http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd ">
<! -- SessionFactory Transaction ************************************* ***** -->
<Bean id = "sessionFactory"
Class = "org. springframework. orm. hibernate3.LocalSessionFactoryBean">
<Property name = "configLocation"
Value = "classpath: hibernate. cfg. xml">
</Property>
</Bean>
--------------------------
</Beans>
Q:
Org. springframework. orm. hibernate3.LocalSessionFactoryBean;
This type does not have the getCurrentSession method at all.
The sessionFactory in productDAO is org. hibernate. SessionFactory. How is the intermediate type converted?
After trying to save it to the database, I couldn't figure out the type conversion. I think LocalSessionFactoryBean didn't implement the SessionFactory interface either? Www.2cto.com
Is it the getObject () method of LocalSessionFactoryBean?
A:
That's it! LocalSessionFactoryBean implements org. springframework. beans. factory. factoryBean interface. If spring implements org during assembly. springframework. beans. factory. the FactoryBean interface uses the FactoryBean # getObject () method to assemble the returned objects. For more information, see the following document.
If you want to get the LocalSessionFactoryBean instance, add '&' to the front of the id. In your configuration file, add BeanFactory. getBean ('& sessionFactory') obtains the instance of LocalSessionFactoryBean.
Author: Tender001