Query all objects that implements a given interface - is that possible?

#1

Hi,

I am trying query one of my DB - for all object types that implement a given interface.

    TypedQuery<Signal_Interface> query =
        em.createQuery("SELECT bk FROM Signal_Interface bk", Signal_Interface.class);

I got the following error. 

I am not sure it is possible to do it - Any suggestion would be appreciated.

Regards,

EKK

Exception in thread "main" [ObjectDB 2.5.1_05] javax.persistence.PersistenceException
Attempt to define unbound variable ('bk') of type Signals.Signal_Interface (error 737)
at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:695)
at DB.DB_for_Signals$ActualDB.ALL(DB_for_Signals.java:105)
at DB.DB_for_Signals.ALL(DB_for_Signals.java:29)
at Signals.Signal_Base.loadAllSignals(Signal_Base.java:170)
at Signals.Signal_Base.main(Signal_Base.java:176)
Caused by: com.objectdb.o.UserException: Attempt to define unbound variable ('bk') of type Signals.Signal_Interface
#2

Try:

    TypedQuery<Signal_Interface> query =
        em.createQuery("SELECT bk FROM Object bk WHERE bk instanceof Signal_Interface",
            Signal_Interface.class);
ObjectDB Support
#3

It worked - thanks a lot

Reply