This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.
Exception in thread "main" java.lang.ClassCastException: org.hibernate.impl.SessionFactoryImpl cannot be cast to org.springframework.orm.hibernate3.annotation.Anno tationSessionFactoryBean
Above exception comes because of invalid casting.
What is the reason you want to get AnnotationSessionFactoryBean from context?
Ahh you want to retrieve the FactoryBean and not the object. Then you need to prefix the name with &. (i.e. '&sessionFactory')
Hello thank you very very very and 1000000000000000000000000000000000000^999999999999 999999999999999999999 very much
it worked very well
this tric, its a magic, can you tell me why, i would to know why we must add this littale prefix ?
When you need to ask a container for an actual FactoryBean instance itself, not the bean it produces, you preface the bean id with the ampersand symbol & (without quotes) when calling the getBean() method of the ApplicationContext. So for a given FactoryBean with an id of myBean, invoking getBean("myBean") on the container returns the product of the FactoryBean, and invoking getBean("&myBean") returns the FactoryBean instance itself.
Note that, AnnotationSessionFactoryBean class implements the spring FactoryBean interface.