Problems using eclipse Hibernate plugin - could not locate sessionfactory in JNDI

后端 未结 2 1052
梦毁少年i
梦毁少年i 2020-12-17 05:14

I\'m using the reverse engineering capabilities built into the eclipse hibernate plugin to generate dao\'s and hbm.xml files for each table.

It does it quite well bu

相关标签:
2条回答
  • 2020-12-17 05:51

    You can either specify all the connection, password, username etc. directly in a hibernate configuration file, and then load using code like:

    Configuration cfg = new Configuration();
    cfg.configure();
    SessionFactory sf = cfg.buildSessionFactory();
    

    Or, you can obtain it from JNDI. This allows your sysadmin to change the connection, password, username etc. after deployment, by registering a different SessionFactory with JNDI.

    You would need to consult your application server's documentation on how to specify JNDI resources with the application server.

    0 讨论(0)
  • 2020-12-17 05:52

    Inside of buildsessionfactory method initialize initialcontext.pass the sessionfactory jndi name in the get session factory method( i.e in lookup)

    0 讨论(0)
提交回复
热议问题