Hibernate version: 3.0
Eclipse version 3.1
I am quite new to hibernate, but have been able to integrate it into several of my Eclipse projects. However, I find that the way I have integrated Hibernate into my projects is somewhat inefficient. This is because each project has its own SessionFactory class. Hence, each project must use its own Session. Now, when I deploy my projects to our webserver I have to have a separate hibernate session for each deployed project. This is because project A may need to use some hibernate enabled classes in project B, so I need to have a one hibernate session for Project A classes and one hibernate session for project B classes.
I am wondering what is the best way to organize my Eclipse projects so that all projects can share a single hibernate session. I have tried to create a separate project that only contains a HibernateSessionFactory class and a hibernate.cfg.xml. And then have all projects reference and use this HibernateSessionFactory. However, I am not sure if this the the best way to handle this.
Any thoughts or suggested reference materials would be appreciated. Thanks.
|