the multi-morph feature of JPQL is not support when using jdoAPI?


We have :
@Inheritance(strategy= InheritanceStrategy.SUBCLASS_TABLE)
@DatastoreIdentity(strategy= IdGeneratorStrategy.SEQUENCE, sequence="jdoid_seq", column="ID")
@Version(strategy=VersionStrategy.VERSION_NUMBER, column="VERSN")
public abstract class SMSMessageAbstract{

public class SMSMessage extends SMSMessageAbstract{

@Inheritance(strategy= InheritanceStrategy.NEW_TABLE)
@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, column="TYP", indexed="true")
@DatastoreIdentity(strategy= IdGeneratorStrategy.SEQUENCE, sequence="jdoid_seq", column="ID")
@Version(strategy=VersionStrategy.VERSION_NUMBER, column="VERSN")
public class SMSMessageProcessed extends SMSMessageAbstract{

When we execute:   select t from izone.adams.model.messaging.SMSMessageProcessed t where t.creationDate>=:p_startDate , we get expected result.
But when we execute:
select t from izone.adams.model.messaging.SMSMessageAbstract t where t.creationDate>=:p_startDate, 
we get exception:

org.datanucleus.exceptions.NucleusUserException: Unable to find table for primary t.creationDate since the class izone.adams.model.messaging.SMSMessageAbstract is managed in multiple tables.

When we execute the jpaql, we are using jdoapi, like:
Query query = pm.newQuery("JPQL", sql);
List results = query.executeResultList(SmsMessageAbstract.class);  //Or SmsMessageProcessed.class, depening on the jpaql. 

Our question is:   According to the above code, seems  jpql  doesn't support multip-morph query when using jdoapi.  Is this an known problem or it is an unexpected bug?

Thanks a lot for any answering.


Define what you mean by "multi-morph feature of JPQL"? Provision of JPQL within JDO provides features that DataNucleus core/rdbms provide, just as JPQL within JPA/Jakarta.

I can't say I ever see a need to use JPQL when using JDO; JDOQL provides for that query.


Hi, Andy,  Thanks for answering.  What I expect is when I run "select t from izone.adams.model.messaging.SMSMessageAbstract t where t.creationDate>=:p_startDate ",  I should be able to get result without exception like  org.datanucleus.exceptions.NucleusUserException: Unable to find table for primary t.creationDate since the class izone.adams.model.messaging.SMSMessageAbstract is managed in multiple tables.  Look at the the exception, it concerns about how to handle multiple morph(return all kind of subclass object of SMSMessageAbstract ).


HI, Andy,  for using jdo api to do jpaql,    we have legacy project which has a lot of jdoql and jpql at the same time. In the past, we used KODO+open jpa at the same time, Now, when we change to datanucleue,  we don't want to maintan persistanceManger and entityManager at the same time any more. But we still want to use the existing JPQLs.


No, there is nothing in the JPA spec that says that.

If you want it then get the code and contribute it


Hi, Andy,   it works in a lot of cases but not this case.  And it is mentioned in the document  as a datanucleus extension.


As i said, the JPA spec defines JPQL and it does NOT say that this query should work, nor does it use the term 'multi morph' anywhere.

DataNucleus allows JPQL to be used with JDO. But that query (candidate class using "subclass-table") is not supported like that, whether using JDOQL or JPQL. As also said, if you want that supported you need to contribute it