-
1. Re: 2.1.0 CR1 - Issue in getResultList
nickarls Oct 2, 2008 7:59 AM (in response to sanghakanwar)Details, details. Show code, tell versions (sun-appserver9.1?)
-
2. Re: 2.1.0 CR1 - Issue in getResultList
sanghakanwar Oct 2, 2008 11:43 AM (in response to sanghakanwar)we are extending EntityQuery and overriding
@Override public List getResultList() { edList = super.getResultList(); return edList; }
Sun-appserver 9.1
mysql version - 6.0
Seam - 2.1.0.CR1exception
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:546) at java.util.ArrayList.get(ArrayList.java:321) at org.jboss.seam.framework.Query.getRenderedEjbql(Query.java:240) at org.jboss.seam.framework.EntityQuery.createQuery(EntityQuery.java:175) at org.jboss.seam.framework.EntityQuery.initResultList(EntityQuery.java:73) at org.jboss.seam.framework.EntityQuery.getResultList(EntityQuery.java:65) at com.prod.sps.session.EventdefinitionList.getResultList(EventdefinitionList.java:44)
-
3. Re: 2.1.0 CR1 - Issue in getResultList
pmuir Oct 2, 2008 12:43 PM (in response to sanghakanwar)Please file an issue in JIRA, with a simple example we can use to reproduce asap so we can get the fix in for the next release.
-
4. Re: 2.1.0 CR1 - Issue in getResultList
sanghakanwar Oct 5, 2008 3:40 PM (in response to sanghakanwar)earlier version had this in the generated entityList.java file which was causing the issue -
@Override public List<String> getRestrictions() { return Arrays.asList(RESTRICTIONS); }
New version generates the following-
@Override public List getRestrictions() { // TODO Auto-generated method stub return super.getRestrictions(); }
-
5. Re: 2.1.0 CR1 - Issue in getResultList
jkronegg Oct 19, 2008 1:17 AM (in response to sanghakanwar)Hi kanwar,
I got the same issue using Seam 2.1.1-SNAPSHOT #340.This is not a bug, but a Seam 2.0.x->2.1.x migration issue, as the seam21migration.txt file state the following:
Seam Application Framework Changes ---------------------------------- Seam now expects value expressions for a number of properties (entityHome.createdMessage, entityHome.updatedMessage, entityHome.deletedMessage and entityQuery.restrictions); if you are using components.xml to configure your objects, you don't need to make any changes. If you are extending the objects in Java, you just need to create a value expression; for example: public ValueExpression getCreatedMessage() { return createValueExpression("New person #{person.firstName} #{person.lastName} created"); }
As me, you probably had the following RESTRICTIONS in your subclass of EntityQuery:
public class MyobjectList extends EntityQuery { private static final String[] RESTRICTIONS = {"lower(myobject.name) like concat(lower(#{myobjectList.myobject.name}),'%')",}; ... public List<String> getRestrictions() { return Arrays.asList(RESTRICTIONS); } }
You must convert the RESTRICTIONS String[] to a org.jboss.seam.core.Expressions.ValueExpression[] (and getRestrictions() must return a List<ValueExpression>). Even simpler, you can use the following convenience method:
import org.jboss.seam.core.Expressions.ValueExpression; public class MyobjectList extends EntityQuery { ... public List<ValueExpression> getRestrictions() { setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS)); return super.getRestrictions(); } }
I did it, it worked like a charm.
By the way, the IndexOutOfBoundException may be a different problem, as the org.jboss.seam.framework.Query.getRenderedEjbql() source code states at line 240:
for (int i=0; i<getRestrictions().size(); i++) { Object parameterValue = restrictionParameters.get(i).getValue();
Notice the for's i<getRestrictions().size() boundary and the restrictionParameters.get(i) which may cause the problem.
Could you correct the
restrictions
migration problem and retry to see if the IndexOutOfBoundException can be reproduced? -
6. Re: 2.1.0 CR1 - Issue in getResultList
joblini Nov 6, 2008 8:27 PM (in response to sanghakanwar)Hi Julien,
Thanks so much for posting this, I am converting my EntityQuery classes as you suggested:
@Override public List<ValueExpression> getRestrictions() { setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS)); return super.getRestrictions(); }
The only thing is that I get a warning :
Expressions.ValueExpression is a raw type. References to generic type Expressions.ValueExpression<T> should be parameterized
Oddly enough, this warning is not issued for the getRestrictions method in the base class, Query.
-
7. Re: 2.1.0 CR1 - Issue in getResultList
joblini Nov 6, 2008 11:24 PM (in response to sanghakanwar)Calling setRestrictionExpressionStrings) does not work for me, it causes parsedRestrictions to be set to null, resulting in a NullPointerException
Line 240 in Query class:
getRestrictions calls setRestrictionExpressionStrings, which calls setRestrictions, which sets parsedRestrictions to null;
for (int i=0; i<getRestrictions().size(); i++) (snip) builder.append( parsedRestrictions.get(i) );
Here is what works for me:
@Override public List<ValueExpression> getRestrictions() { return toValueExpressionList(Arrays.asList(RESTRICTIONS)); } public List<ValueExpression> toValueExpressionList(List<String> expressionStrings) { List<ValueExpression> expressionList = new ArrayList<ValueExpression>(expressionStrings.size()); for (String expressionString : expressionStrings) { expressionList.add(Expressions.instance().createValueExpression(expressionString)); } return expressionList; }
-
8. Re: 2.1.0 CR1 - Issue in getResultList
joblini Nov 7, 2008 5:47 PM (in response to sanghakanwar)Correct implementation is posted here (call setRestrictionExpressionStrings from constructor, not from getRestrictions)