Welcome to the new Spring.io forums!
If this is your first visit, be sure to check out the
by clicking the link above, and for security reasons, use the
forgot password link to reset your password..
You may have to register before you can post: click the register
link above to proceed. To start viewing messages, select the forum that you want to visit
from the selection below.
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.