• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate 5.0.0 - Mapping in hibernate.cfg.xml ignored?

 
A. Koch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

I am quite new to hibernate and was using version 4.3 until now. I upgraded to 5.0.0, as I wanted to take advantage of the Java 8 features.

I have no annotations in my code and use the "hibernate.cfg.xml"-file with ".hbm.xml"-files for each persisted class. Until now, everything worked fine, but since the upgrade, my mappings in "hibernate.cfg.xml" seem to be totally ignored...

Doing a query leads to
Doing a save or update operation leads to
Everything works fine, when I add the resources programatically in the configuration with Unfortunately, this process takes more then a second for each persisted class, which wasn´t the case earlier with the config-file...

Can anybody tell me, why the mapping in the "hibernate.cfg.xml"-file doesn´t seem to work anymore? It is definitely read, as other parameters are recognized.

Thank you for any advice
Andy

Excerpt from hibernate.cfg.xml


Excerpt from SessionFactory


(sorry for this cross-posting from https://forum.hibernate.org/viewtopic.php?f=1&t=1041405 - this forum seems to be flooded with spam right now )
 
Marco Behler
Author
Ranch Hand
Posts: 43
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you try this to create your SessionFactory:

 
A. Koch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, this seems to work fine . In addition to your proposed code I only had to change <session-factory name=""> to <session-factory> in my "hibernate.cfg.xml", as I got a JNDI-naming Exception. Thank you very much!!!

Is there any note in the official documentation, that using "configuration.buildSessionFactory(serviceRegistry);" does not work as expected? I couldn´t find any...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic