Fast Object Database for Java - with JPA/JDO support

Why does ObjectDB duplicate classes from javax.jdo:jdo-api?



I'm using the Java Persistence API (JPA) in a library to not lock myself in to using a specific database. In a project that uses said library, I'm using ObjectDB because it is fast and eliminates the need for another dependency to an ORM, such as Hibernate, since it implements the JPA. ObjectDB's been doing a great job so far and I'm glad I found it.

However, I recently wanted to add an index to a field that is an element collection and encountered an issue with duplicate classes. To use the @Index annotation, I had to add a dependency to the JDO API version 3.1. The code works just fine, but when I use a Maven plugin to detect duplicate classes and resources, it points out that both ObjectDB and the JDO API expose the same classes.

I was wondering: is there was a reason why the ObjectDB JAR contains packages and classes that clash with the JDO API's JAR?

If a project uses JPA and JDO, it is most likely to avoid coupling it to a specific database. By adding ObjectDB as a database and ORM in a project, it seems odd that it would clash with classes that are already provided by the JDO API which is an abstraction (I believe). Furthermore, I believe and finding the same packages in two different modules can be problematic in projects that use Java 9 modules.

I've created a sample project that produces the warnings I am referring to:




You are right, of course. JDO files should be removed from the objectdb.jar file.

When ObjectDB 2.0 was released many years ago, one appealing point was that it had a single JAR file with no external dependencies (e.g., compared to Hibernate, etc.). However, this was taken to the extreme, and the inclusion of JPA and JDO in objectdb.jar was a mistake, and obviously conflicts with modern methods and tools. To solve the conflict with JPA, two different jar files are now provided when you download ObjectDB, objectdb.jar (with JPA) and objectdb-jee.jar (without JPA). The JAR files on the Maven repository now excludes the JPA files. Similar action has not been taken yet regarding JDO due too its much lower popularity.

This will be solved in future versions of ObjectDB, but not immediately, to avoid difficulties for existing users and projects. Assuming you do not use JDO 3.1 except for the Index annotation (actually ObjectDB supports JDO 2 rather than 3.1) then removing dependency on JDO 3.1 may be the best current workaround.

On a different matter, due to a recent upgrade of our website we had issues with permissions to edit forum posts. We are monitoring the log closely and noticed your attempts to edit your post. Editing should work now. Sorry for the inconvenience.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

The workaround you suggested should work. Thanks for the quick reply!

Should I open an issue for this technical debt?


This thread is now included also in the Issue Tracking.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply