留言板

Liferay OSGI Service integration to hibernate

ronak dhruv,修改在6 年前。

Liferay OSGI Service integration to hibernate

New Member 帖子: 4 加入日期: 15-4-9 最近的帖子
hi,
I created one service module instead of service builder module.
I used hibernate in place of service builder in my service module. Is there any another way to do it in liferay service module or solution to this existing implementation ?
I tried to do the same by . I load hibernate configuration file from external path.
for example:
File f = new File("D:\\fax\\hibernate.cfg.xml");
SessionFactory sessionFactory = new Configuration().configure(f).buildSessionFactory();

I got the connection of hibernate to my service but the problem i am facing is that not able to load my model entity which is defined in configuration file of hibernate.
thumbnail
David H Nebinger,修改在6 年前。

RE: Liferay OSGI Service integration to hibernate (答复)

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
ronak dhruv:
I used hibernate in place of service builder in my service module. Is there any another way to do it in liferay service module or solution to this existing implementation ?


No, SB uses its own spring/hibernate contexts and you cannot pull them together.

Usually I recommend avoiding trying to use JPA or Hibernate directly, mostly because developers tend to forget things like how to coordinate cache management under varying scopes, especially with respect to cluster caching, and for many other reasons.

I tried to do the same by . I load hibernate configuration file from external path.
for example:
File f = new File("D:\\fax\\hibernate.cfg.xml");
SessionFactory sessionFactory = new Configuration().configure(f).buildSessionFactory();


This too is also a very bad idea. It means that the configuration file will be permanently stuck in one place, and this tends to fail when you change servers or share with other developers, clients, etc.








Come meet me at 2017 LSNA!