This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I specify a directory or directories of classes in hibernate.cfg.xml?  RSS feed

 
david zhang
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am learning Hibernate and JPA Annotation. The following is what I use to make Hibernate be aware of JPA-annotated classes:

......
config.addAnnotatedClass(Thing.class);
config.addAnnotatedClass(Fracture.class);
config.addAnnotatedClass(Interest.class);
config.addAnnotatedClass(Ancestor.class);
config.addAnnotatedClass(Parent.class);
......

It is very tedious to add every class like the above.

Is there any way I can use to specify all JPA-annotated classes in a directory or directories in Hibernate.cfg.xml?

Thanks for your help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!