Spring provides options to integrate many ORM frameworks available in Market and one of them is Hibernate. With the options like configuring SessionFactory and HibernateTemplate, it makes developer’s life smooth to integrate other cross cutting concerns. Amongst all the other features, Spring provides a convenient feature is to autodetect “Annotated” Entity classes from package(s) using helper bean “org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean”. The package(s) name can be injected using setter method “packagesToScan”. Set the value of this property to the package name where you place the Entity classes and you are good to go. No need to add entry for every *-hbm.xml file OR explicitly configuring annotated classes.
But recently I came across a problem, wherein I found that my application’s Entity classes were not detected and when I was querying, hibernate was simply throwing an error as “XXX is not mapped”.