How to use Hibernate from an Eclipse plugin?

I am writing an Eclipse plugin that loads resources from a central database. I would like to use Hibernate to access this database.

So, how can I add this as a dependency on my plug-in project? I tried Google, but only get hits about plugins for editing Hibernate configuration files.

+3
source share
2 answers

I would create a hibernate plugin that exposes all jibernate jar files and exports the contained classes. My configuration and data will then be in another plugin, which depends on sleep mode.

Then, since hibernate uses reflection like tomorrow does not, the Hibernate plugin should be able to load classes from plug-ins that depend on it. For this you need to use the Eclipse-BuddyPolicy directive. Check out this documentation for loading classes on eclipse that mentions BuddyPolicy

I installed the Kodo JDO plugin using this method and it works very well. Sample from my Manifest.mf attached

Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Solarmetric Kodo Bundle-SymbolicName: com.solarmetric.kodo Bundle-Activator: com.solarmetric.kodo.KodoPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime Eclipse-AutoStart: true Eclipse-BuddyPolicy: global Export-Package: com.solarmetric.ant, com.solarmetric.apache.commons.collections, com.solarmetric.apache.commons.collections.buffer, com.solarmetric.apache.commons.collections.collection, com.solarmetric.apache.commons.collections.functors, com.solarmetric.apache.commons.collections.iterators, com.solarmetric.apache.commons.collections.keyvalue, 
+1
source

You can follow standard hibernation tutorials, such as the documentation provided by hibernate.org or the Gaven Kings book, for using hibernation in conjunction with the eclipse rcp project.

The easiest way is to include your Hibernate related code and your configuration in the plugin you are currently developing.

Therefore, your plugin should depend on jar files, depends on each hibernation project. You can also provide these libraries with a separate plugin and simply export them.

But you must remember that hibernate makes heavy use of reflection, and your persistent classes should be available to your persistence manager.

There is also a very good tutorial on integrating hibernate as a separate plugin at http://entwickler.de/zonen/portale/psecom,id,101,online,1082,.html , but unfortunately it is only available in German.

0
source

All Articles