Is it possible get the All PrimKeys for a given entity class in the DB?

#1

Hi,

I would like to retrieve all the primKeys (user defined) by doing something like:

    TypedQuery<MyClassPrimKey> query =
        em.createQuery("SELECT mif.primkey FROM MyClass mif", MyClassPrimKey.class);

The only alternative I can think of - would be to store the primkey on the object - but sounds like it is double storage

Thanks

#2

It should be possible using a JDO's method in the query:

SELECT JDOHelper.getObjectId(e) FROM MyEntity e

But this is not JPA portable, of course.

Anyway, adding @Id field doesn't duplicate storage. The field is initialized each time the entity object is loaded. But the effect on performance is expected to be minimal, and the database size will not change.

ObjectDB Support

Reply