Hello all!
I have a question that doesn't seem to be too common on the message boards. If anyone has any ideas, please feel free to share them! =)
I have a table in my database called Person.
The primary key is personseq, an integer value.
I am trying to (for the sake of experimentation) run the equivalent of this SQL query:
-------------------------------
select max(personseq)
from Person
-------------------------------
I'm running
EJB 2.0 and Orion/oc4j. I wanted to do this in an ejbSelect method, because I only want one field returned - not the entire list of objects that an EJB find would return. I've read that 2.0 supports the aggregate functions.
So I have a Person entity bean, and that entity bean has an abstract method: ejbSelectMaxPersonseq(), which returns a Long, and throws a FinderException.
The ejb-ql I've written for this method is as follows:
-------------------------------
select max (o.personseq) from Person o
-------------------------------
This compiled fine, but broke upon deployment with this error:
<snip>
06/07/31 17:25:01 WARNING: EJBContainer.postInit Error generating wrappers for file: <filename here>
java.lang.NullPointerException
at com.sun.enterprise.deployment.QueryDescriptor.getSQLAsPrintableString(QueryDescriptor.java:158)
at com.evermind.server.ejb.compilation.SelectMethodCompilation.compile(SelectMethodCompilation.java:67)
at com.evermind.server.ejb.compilation.CMPObjectCompilation.verifyMethods(CMPObjectCompilation.java:775)
at com.evermind.server.ejb.compilation.CMPObjectCompilation.<init>(CMPObjectCompilation.java:56)
at com.evermind.server.ejb.compilation.PersistenceManagerCompilation.<init>(PersistenceManagerCompilation.java:30)
at com.evermind.server.ejb.compilation.EntityBeanCompilation.<init>(EntityBeanCompilation.java:121)
at com.evermind.server.ejb.compilation.Compilation.generateAnyOldStyle(Compilation.java:1590)
at com.evermind.server.ejb.compilation.Compilation.compile(Compilation.java:182)
at com.evermind.server.ejb.compilation.Compilation.doGenerateCode(Compilation.java:250)
at com.evermind.server.ejb.EJBContainer.postInit(EJBContainer.java:891)
at com.evermind.server.ApplicationStateRunning.initializeApplication(ApplicationStateRunning.java:210)
at com.evermind.server.Application.setConfig(Application.java:391)
at com.evermind.server.Application.setConfig(Application.java:308)
at com.evermind.server.ApplicationServer.addApplication(ApplicationServer.java:1771)
at oracle.oc4j.admin.internal.ApplicationDeployer.addApplication(ApplicationDeployer.java:507)
at oracle.oc4j.admin.internal.ApplicationDeployer.doDeploy(ApplicationDeployer.java:191)
at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:93)
at com.evermind.server.administration.DefaultApplicationServerAdministrator.internalDeploy(DefaultApplicationServerAdministrator.java:446)
at com.evermind.server.administration.DefaultApplicationServerAdministrator.deploy(DefaultApplicationServerAdministrator.java:347)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:53)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595)
Jul 31, 2006 5:25:01 PM com.evermind.server.ejb.EJBContainer postInit
WARNING: Error generating wrappers for file:<jar file name here>
<snip>
I assumed that my ejb-ql was incorrect, so I abandoned the aggregate, and made it a simpler one-field select, and tried this ejb-ql (jobId and personseq are both cmp fields w/Long values in the entity bean):
-------------------------------
select o.jobId from Person o
where o.personseq = 13543
-------------------------------
This compiled fine, and deployed with no errors.
Is there a glaring error in my max ejb-ql I'm not seeing? Has anyone run across this problem before?
If so, any insight would be appreciated! =)
Thanks to all! =)
-Em
p.s. I encountered the original "max" problem while developing a different app I was creating in Toplink, and the error message was different (a NPE way down in Toplink's UOWManager). This Orion version is me attempting to see if I can get it working "the old way", hoping the solution might translate to Toplink. So if you've solved a similar issue in Toplink, that'll be helpful too!