Skip to main content

'Invalid column index' error while executing the ejb-ql

3 replies [Last post]
suneelgv
Offline
Joined: 2008-07-07

Hi,

I've the following ejbql:

Find all siblings for given CategoryId

findByCategoryIdAllSiblings

int
int

SELECT OBJECT(o) FROM Category o ,Category category
WHERE category.categoryId = ?1 AND
o.parentCategoryId = category.parentCategoryId
AND o.categoryRootId = ?2
ORDER BY o.displayOrder

When calling the finder method, glassfish throws the following error:

[#|2008-08-14T11:18:52.473-0500|WARNING|sun-appserver9.1|javax.enterprise.system.container.ejb.entity.finder|_ThreadID=18;_ThreadName=httpSSLWorkerThread-7001-1;_RequestID=d2c76291-f135-41dc-8fbd-809f4f743125;|JDO74009: Bean 'Category' method ejbFindByCategoryIdAllSiblings: problems running JDOQL query with params [279, 89]
com.sun.jdo.api.persistence.support.JDODataStoreException: JDO76400: Got a JDBC SQLException while executing the SQL statement:
SQL statement with input values:java.lang.Integer:279, java.lang.Integer:89.
Please examine the SQLException for more information.
NestedException: java.sql.SQLException: Invalid column index
at com.sun.jdo.spi.persistence.support.sqlstore.SQLStoreManager.throwJDOSqlException(SQLStoreManager.java:645)
at com.sun.jdo.spi.persistence.support.sqlstore.SQLStoreManager.executeQuery(SQLStoreManager.java:479)
at com.sun.jdo.spi.persistence.support.sqlstore.SQLStoreManager.retrieve(SQLStoreManager.java:376)
at com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerImpl.retrieve(PersistenceManagerImpl.java:1118)
at com.sun.jdo.spi.persistence.support.sqlstore.query.QueryImpl.doExecute(QueryImpl.java:689)
at com.sun.jdo.spi.persistence.support.sqlstore.query.QueryImpl.executeWithArray(QueryImpl.java:607)
at com.biperf.services.awardslinqservices.ejb.entity.category.CategoryEJB_132568754_ConcreteImpl.ejbFindByCategoryIdAllSiblings(CategoryEJB_132568754_ConcreteImpl.java:760)
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.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.EJBLocalHomeInvocationHandler.invoke(EJBLocalHomeInvocationHandler.java:237)
at $Proxy132.findByCategoryIdAllSiblings(Unknown Source)
at com.biperf.services.awardslinqservices.ejb.session.catalog.command.CategoryHierarchyGetter.getCategoryList(CategoryHierarchyGetter.java:150)
at com.biperf.services.awardslinqservices.ejb.session.catalog.command.CategoryHierarchyGetter.moveCategory(CategoryHierarchyGetter.java:113)
at com.biperf.services.awardslinqservices.ejb.session.catalog.CatalogFacadeBean.moveCategory(CatalogFacadeBean.java:312)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

Please let me know what I am doing wrong.

Thanks
Suneel

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Mitesh Meswani

>select t0."CATEGORY_ID", t0."CATEGORY_NAME", t0."PARENT_CATEGORY_ID", t0."DISPLAY_ORDER", t0."VERSION" from "AAHM_CATEGORY" t0, "AAHM_CATEGORY" t1 order by t0."DISPLAY_ORDER"

I do not see anything wrong with the SQL above. Which database you are
executing against? Have you tried directly executing the sql against
database using its native tool to see which part is not liked by the
database.

Not directly related but, one strange thing to observe here is that
where clause in generated SQL does not contain the conditions from where
clause you have specified in your EJBQL. Is it possible that you are
packaging a different version of descriptors than shown in your post?

Thanks,
Mitesh

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

suneelgv
Offline
Joined: 2008-07-07

Thanks for the reply Mitesh. The SQL executes fine in Oracle client. One of the team members came with the reason that it might be because we are joining with another table (or same table in this case) and glassfish is getting confused in picking the columns. All other queries in the ejb-jar.xml don't have joins with other ejbs. This is the only one different from rest. So we had to write two different ejb-qls and merge the results in java code.

I know the reason sounds too absurd :-) . But I couldn't come up with a better reasoning. And yeah, deployed descriptor is same as the one shown.

Tx
Suneel

jmarine
Offline
Joined: 2006-09-24

Hi Suneel,

What is also absurd is that sometimes it's possible to help GlassFish to generate the correct SQL statements with only changing the order of conditions (to previously concrete the other ejbs, before comparing their fields/relations).

I think you had get the desired results with this other EJBQL statement:

SELECT OBJECT(o) FROM Category o ,Category category
WHERE category.categoryId = ?1
AND category.parentCategoryId = o.parentCategoryId
AND o.categoryRootId = ?2
ORDER BY o.displayOrder

Would you want to try the proposed statement?

If it works, it could be a similar problem you had with "NOT MEMBER OF" operator (http://forums.java.net/jive/thread.jspa?threadID=45567&tstart=0)...
And it may be worth to open an issue ?