使用Hibernate与动态Eclipse插件 [英] Using Hibernate with Dynamic Eclipse Plug-ins

查看:125
本文介绍了使用Hibernate与动态Eclipse插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的类的命名与我用于我的应用程序的不同插件的命名完全相同,我希望能够使用Hibernate正确配置它们。问题在于,当它正在进行映射时,试图找到一个类时,它看起来像是Hibernate动态生成一个类的包名。有一个插件这个方案是有效的,但跨多个插件它不工作。在多个插件处理Hibernate配置文件时,Hibernate看起来很困惑。

I have classes that are named exactly the same across different plug-ins that I use for my application, and I'd like to be able to configure them properly with Hibernate. The problem is that it looks like Hibernate dynamically generates a class' package name when trying to find a class when it's doing its mapping. With one plug-in this scheme works, but across multiple plug-ins it's not working. It looks like Hibernate gets confused when dealing with Hibernate configuration files across multiple plug-ins.

这是因为每个插件都有自己的类加载器?使用现有插件和Hibernate进行此工作的最佳方法是什么?

Is this because each plug-in has its own class-loader? What is the best way to proceed to make this work with the existing plug-ins and Hibernate?

推荐答案

问题是,每个插件都有自己的Classloader,Hibernate使用Reflection来找到正确的类。

The problem is, that every plugin has its own Classloader and Hibernate uses Reflection to find the right classes.

我在家里有一个非常好的文章,完全是这个问题,但是这是一个德文。我将尝试解释你需要做什么。

I have a very nice article at home about exactly this problem, but this one is in German. I will try to explain what you need to do.

为了使数据结构在多个插件上共享,您必须将其放在一个插件中,并启用一个名为的伙伴的策略即可。
假设你有一个主应用程序插件,它启动时启动hibernate,这个插件需要从数据结构插件中看类。要做到这一点,主插件将其Buddy-Policy设置为注册,并且datastructure-plugin将其自身注册为好友。不幸的是,你必须直接在清单文件中完成所有操作,至少在3.3中,编辑器中没有办法。

In order to have the datastructure shared over several plugins, you have to put it in a plugin and enable a feature called buddy-policy. Lets say you have a main-application-plugin which is initiating hibernate on startup, this plugin needs to "see" the classes from the datastructure-plugin. To do this the main-plugin sets its Buddy-Policy to "registered" and the datastructure-plugin registers itself as a "buddy". Unfortunately you have to do this all directly in the manifest file, at least in 3.3 there was no way to do this in the editor.

政策工作,Hibernate也将。

我查了我的旧应用程序,这里是我如何做的。

I looked up my old application and here is how I did it.


  1. 主应用程序(toolseye.rcp)取决于hibernate插件(de.eye4eye.hibernate)和datastructure-plugin(toolseye.datastructures)

  2. hibernate-plugin将其好友策略指定为已注册

  3. datastructure-plugin将自身注册到hibernate-plugin



    以下是重要的一行:

Here are the important lines:

Hibernate-plugin de.eye4eye.hibernate

Hibernate-plugin de.eye4eye.hibernate

Eclipse-BuddyPolicy: registered

Datastructure-plugin toolseye.datastructures

Datastructure-plugin toolseye.datastructures

Eclipse-RegisterBuddy: de.eye4eye.hibernate

把这些行直接在MANIFEST.MF中

Put those line directly in the MANIFEST.MF

两个插件都需要重新导出他们的包,以便主应用程序或其间的任何层可以使用它们。
希望有所帮助。

Both plugins need to reexport their packages in order that the main application or whatever layer you have in between can use them. Hope that helped.

这篇关于使用Hibernate与动态Eclipse插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆