siva636
siva636

Reputation: 16441

How AnnotationSessionFactoryBean and SessionFactory are of the same type?

In a typical Hibernate Spring application, we configure AnnotationSessionFactoryBean something like following:

<bean id="sessionFactory"       class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
        p:dataSource-ref="dataSource"
        p:packagesToScan="com.company.model"
        p:hibernateProperties-ref="hibernateProperties" />

Now we can inject SessionFactory in our DAOs:

@Autowired org.hibernate.SessionFactory ssessionFactory;

That means AnnotationSessionFactoryBean and ssessionFactory are of the same type, that implies they should have superclass subclass relationship. But I can't find such relationship from the API docs. What am I missing? How they are of the same type?

Upvotes: 1

Views: 228

Answers (1)

Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 279990

No, they aren't of the same type. AnnotationSessionFactoryBean is a FactoryBean. This is a special interface managed by Spring which produces a bean of some type. AnnotationSessionFactoryBean produces a SessionFactory.

Upvotes: 2

Related Questions