Problem Using Reflection


I'm currently working on developing my own API to use with ObjectDB and I'm running into the following problem.  Using the API I can insert data into an empty database without any issues; however, whenever I try to add new data to the database for a class that already has data stored, I get the following exception:

 java.lang.ClassCastException: SimpleObjectDso cannot be cast to com.objectdb.spi.TrackableUserType

Just for some background.  SimpleObject is a POJO.  SimpleObjectDso is created using reflection and is the JPA entity class.  Like I said, I can add data for this class when the database is empty without any problems.  Trying to add data once data has already been added for this class, produces this exception.

Any insight into why and how I can avoid this exception?

Thanks in advance.


Please post a full stack trace of the exception.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
java.lang.ClassCastException: objectdbtest.SimpleObjectDso cannot be cast to com.objectdb.spi.TrackableUserType

The exception is thrown for an entity class that is expected by ObjectDB to be enhanced but actually it is not. Similar exceptions are thrown when hierarchy of classes is partly enhanced (you have to enhance all the classes in an entity inheritance path or none).

If you do not use enhancement it could be associated with synthetic classes that ObjectDB builds and enhances for classes with instances in the databases that their entity class cannot be found in your application. This could cause various issues. If you build the classes dynamically make sure that these classes are available to ObjectDB in the ordinary application classpath or the thread context classpath, so no synthetic classes are generated.

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

Thanks.  I'll investigate further.

Post Reply

To post a reply and/or subscribe to update notifications - please login