java - What's the result of HQL select from an interface which have two implemented classes -


i have interface named customer, these 2 classes customerimpl , ownercustomerimpl both implemented interface, have hql "select customer customer customer customer.username=:username", what's result of hql?

i objects of customerimpl, want ownercustomerimpl.

i read doc like:

14.8. polymorphic queries

a query like:

from cat cat

returns instances not of cat, of subclasses domesticcat. hibernate queries can name java class or interface in clause. query return instances of persistent classes extend class or implement interface. following query return persistent objects:

from java.lang.object o

the interface named might implemented various persistent classes:

from named n, named m n.name = m.name

these last 2 queries require more 1 sql select. means order clause not correctly order whole result set. means cannot call these queries using query.scroll().

as think, result should include both these 2 classes, can explain this?

yes, according hibernate, both customerimpl , ownercustomerimpl instances should returned. check if have persisted instances both of classes.

also check if implement same customer interface (and not 1 package).

also check if result not complete list (e.g. first x elements) because if result limited, quoted hibernate may choose return customerimpl instances first meet criteria , include ownercustomerimpl after that.

also don't have ownercustomerimpl persisted instances match query condition.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -