in my applicationContext.xml, this is how I map xml to POJO. how to map directory to class file without required to create xml?
Instead of using XML mapping files, you can use the Hibernate Annotations library which is based on Java 5 annotations.
As usual, you'll need to declare your persistence classes in the Hibernate configuration file (typically hibernate.cfg.xml
), though you use the
element to declare your persistent classes:
If you are using the Spring framework, you can set up an annotation-based Hibernate session factory using the AnnotationSessionFactoryBean
class, as shown here:
org.hibernate.dialect.DerbyDialect
create
...
com.mycompany.sample.domain.Order
com.mycompany.sample.domain.LineItem
...