No1UNo wrote:
> 
> 
> Pinaki Poddar wrote:
>> 
>> try:
>>   javax.persistence.Query q = em.createQuery(aJPQLString);
>>   q.setHint("openjpa.Subclasses", "false");
>> 
> 
> This promises to be exactly the solution I need to an optimization
> issue...but it does not work for me in OpenJPA 1.2.1.  The 1.2.x
> documentation does not mention this parameter anywhere I could find, but
> the 'org.apache.openjpa.persistence.HintHandler' class in OpenJPA 2.0
> does.  I assumed this must be a 2.0 feature.
> 
> So I fell back to trying openjpa.jdbc.SubclassFetchMode, but the child
> classes were returned.  I tried annotating with
> '@SubclassFetchMode(value=FetchMode.NONE)', but again the child classes
> were returned.  I then searched through the 1.2.1 source code and found,
> to my surprise, at
> 'openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java'
> in the 'setHint' function that this is indeed supported in 1.2.1.  But
> again, the child classes are returned.
> 
> Does the setHint call need to be performed in combination with something
> else?
> 

Given classes Y and Z descended from X via joined inheritance, I am
attempting to do the following:

        Query dbQuery = em.createNativeQuery("SELECT * FROM xTable WHERE ...",
X.class);
        dbQuery.setHint("openjpa.Subclasses", "false");
        List<X> results = dbQuery.getResultList();

The intent is to quickly scan through the table for appropriate matches. 
This might then return a large list.  Then followups look at specific
subsets.  I am hoping to disable subclass resolution in the initial search
but retain it for all subsequent ones.

Following in the debugger, I can see that the setHint function does
establish a new extent within the query for which subclasses is false.  I do
not, however, see this information being used in the query execution.

Any guidance or even crazy suggestions would be welcome.


-- 
View this message in context: 
http://n2.nabble.com/How-to-disable-jpql-Polymorphic-Queries-tp3229800p4282153.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to