Problem Using Reflection

#1

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.

#2

Please post a full stack trace of the exception.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3
java.lang.ClassCastException: objectdbtest.SimpleObjectDso cannot be cast to com.objectdb.spi.TrackableUserType
com.objectdb.o.UMR.h(UMR.java:750)
com.objectdb.o.UMR.g(UMR.java:715)
com.objectdb.o.ENT.k(ENT.java:468)
com.objectdb.o.ENT.k(ENT.java:398)
com.objectdb.o.STA.L(STA.java:895)
com.objectdb.o.STM.j(STM.java:598)
com.objectdb.o.OBM.aC(OBM.java:1090)
com.objectdb.o.OBM.aS(OBM.java:871)
com.objectdb.o.OBM.aG(OBM.java:759)
com.objectdb.jpa.EMImpl.commit(EMImpl.java:286)
objectdbtest.OdbConnection.commitTx(OdbConnection.java:80)
objectdbtest.ObjectDbTest.main(ObjectDbTest.java:41)
#4

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)
#5

Thanks.  I'll investigate further.


Post Reply

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