简体   繁体   English

Spring-Hibernate应用程序与EJB-Hibernate应用程序集成?

[英]Spring-Hibernate Application Integration with EJB-Hibernate Application?

I have a EJB-Hibernate application, and currently I am trying to integrate another application which is built in Spring-Hibernate . 我有一个EJB-Hibernate应用程序,当前正在尝试集成在Spring-Hibernate中构建的另一个应用程序。

Now the issue is, as both of them are using Hibernate, I am confused how to integrate their hibernate configs? 现在的问题是,因为他们两个都在使用Hibernate,所以我很困惑如何集成他们的hibernate配置?

Again both of them use different way of writing Hibernate configs also, ie Spring based app uses through Spring beans and hibernate-cfg.properties file, 同样,他们两个都使用不同的方式编写Hibernate配置,即通过Spring bean和hibernate-cfg.properties文件使用基于Spring的应用程序,

Whereas EJB application is doing it, a standard hibernate way (ie xxx-cfg.xml and xxx-hbm.xml), EJB应用程序正在这样做,这是一种标准的休眠方式(即xxx-cfg.xml和xxx-hbm.xml),

So I am confused, what should be my approach? 所以我很困惑,我应该怎么做? Any help is welcome. 欢迎任何帮助。


Sorry I forgot to mention Versions --> 对不起,我忘了提到版本->

In EJB Application --> EJB 2.0 and Hibernate 3.1.3 & Spring Application, Spring 3.x and Hibernate 3.2.6 在EJB应用程序-> EJB 2.0和Hibernate 3.1.3和Spring应用程序中,Spring 3.x和Hibernate 3.2.6

And in Spring-Hibernate Application they have their own cache implementation, currently both are referring to separate datasources and separate Db-schemas. 在Spring-Hibernate Application中,它们具有自己的缓存实现,目前两者都引用了单独的数据源和单独的Db模式。

I want to integrate them so that, both will have same db-schema (I will do that by merging their schemas ie adding tables,etc. to current schema) and same datasource (Here we are using JBoss to manage datasource connections through xxx-ds.xml) 我想将它们集成在一起,以便两者都具有相同的db模式(我将通过合并它们的模式(即向当前模式添加表等)来做到这一点)和相同的数据源(这里我们使用JBoss通过xxx-管理数据源连接ds.xml)

EJB-Hibernate Application we have mentioned the JNDI name of this datasource, so it refers to that. EJB-Hibernate Application我们已经提到了此数据源的JNDI名称,因此它引用了该名称。 But in Spring App, they are having their separate datasource, but I can make it reference same using same JNDI name. 但是在Spring App中,他们拥有各自的数据源,但是我可以使用相同的JNDI名称使其引用相同。

Please tell me, how should I do this integration? 请告诉我,我应该如何进行集成?

Your information seems to be a bit confusing but I would try to gather from what you have mentioned. 您的信息似乎有些混乱,但是我会尝试从您提到的内容中收集信息。

When you say that you want to intergrate both applications, then apart from using a common datasource are you trying to get rid of EJB 2 in your application and use Spring instead ? 当您说要集成两个应用程序时,除了使用公共数据源之外,您还尝试在应用程序中摆脱EJB 2并改用Spring吗? This will require migration from EJB2 to Spring. 这将需要从EJB2迁移到Spring。 For this there are plenty of articles like this one. 对于这个有很多的类似文章一个。

Or if what you want is that both the applications should exists independently but should use single schema then as you stated you can merge both schemas into one, register the datasource in JNDI. 或者,如果您想要两个应用程序都应该独立存在但应该使用单个架构,则可以将两个架构合并为一个,在JNDI中注册数据源。 Then use can use the same datasource in both different applications. 然后使用可以在两个不同的应用程序中使用相同的数据源。 EJB2 and Spring both can use a JNDI bound datasource. EJB2和Spring都可以使用JNDI绑定的数据源。

In case both applications exist independently and one of them is using hibernate second level cache ( as you mentioned) then you will have to be careful as your cache will be invalidated very often as your database will be shared between two application which can write to database. 如果两个应用程序都独立存在,并且其中一个正在使用休眠二级缓存(如您所述),那么您将必须小心,因为缓存将非常无效,因为数据库将在两个可以写入数据库的应用程序之间共享。 In fact in such cases it's wise only to cache ONLY read-only data which never changes. 事实上,在这种情况下,明智的做法只是为了缓存ONLY只读从不改变的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM