1

Let's say I create an object in java named Point with 2 attributes (int x & int y) and i store some instances in an objectdb file. I know how to retrieve all items (as objects) from that file but how can I access their attributes if I don't have the definition of the class Point anymore?

Point definition

Class Point {
    int x;
    int y;
}

Then I create 2 Points (0,0) (1,1) and store them in objectdb file (i can provide the code if needed)

I retrieve all Point instances with this statement

     TypedQuery<Object> query = em.createQuery("SELECT o FROM Object o", Object.class);
     List<Object> results = query.getResultList();

Supposedly i only have the objectdb file and not the Point class definition how can i get the values of x and y (even as simple string values)?

Thanks in advance

AkiS
  • 47
  • 2
  • 9

1 Answers1

0

When a class definition is missing ObjectDB automatically generates a synthetic class according to the class schema as stored in the database. Therefore the query in your example returns instances of a synthetic Point class generated by ObjectDB.

You can access your data using the Java Reflection API (possibly using also the JPA Metamodel API).

ObjectDB
  • 1,312
  • 8
  • 9