Hello,
I'm trying to use ObjectDB in an OSGi environment (Karaf 4.0.7).
I'm now facing ClassCastExceptions on my "entity" classes when I try to read data from the DB.
In a very old (2011?) forum entry this problem was already discussed and it appears to be related to classloader problems.
My entity is a dedicated bundle.
I have one bundle with the database service (doing the actual objectdb actions -> persist, query etc).
I have one business bundle that handles the "business" actions.
The entity obviously has to get loaded by all bundles in order to manipulate the data.
This is the code that seems to throw the exception:
@Override
public Person loadPerson(final Integer id) {
TypedQuery<Person> typedQuery = entityManager.createQuery("SELECT FROM Person p WHERE p.id = 1", Person.class);
Person singleResult = typedQuery.getSingleResult();
System.out.println(singleResult);
return singleResult;
}
Is there a solution to this problem?
I'm not sure if restricting the use of the Entity class to the database service only and the using DTOs could solve the problem but I would mean doubling the classes and having to move data around between the Entities and DTOs.
Many thanks in advance for your support,
Alex