Hi all,
I'm using
JBoss 4.0.2, and I try to access to a HSQLDB-table with a finder-method.
The name of the HSQLDB-table is RecipePos and it has the following fields:
RECIPEID (CMP-Integer-field and part of the primary-key)
RECIPEPS (CMP-Integer-field and part of the primary-key)
RECIPEPOSPK (Primary-Key-compound-class)
SIDE (CMP-String-field)
WORKDESC (CMP-String-field)
MACHINE (CMP-String-field)
COUNT (CMP-String-field)
COLOR (CMP-String-field)
RECIPEDESC (CMP-String-field)
COMMENT (CMP-String-field)
This is my primary-key-compound-class:
public class RecipePosPK implements Serializable {
public java.lang.Integer recipeId;
public java.lang.Integer recipePs;
public RecipePosPK() { }
public boolean equals(Object obj) {
if (this.getClass().equals(obj.getClass())) {
RecipePosPK other = (RecipePosPK) obj;
return (this.recipeId.intValue() == other.recipeId.intValue()
&& this.recipePs.intValue() == other.recipePs.intValue());
}
return false;
}
public int hashCode() {
return(("" + recipeId.intValue()
+ recipePs.intValue()).hashCode());
}
}
I want to search for all recipe-positions with a specific ID-number. Thus, I have created the following finder-method:
@ejb.finder signature="java.util.Collection
findRecipe(java.lang.Integer recipe)"
query="SELECT OBJECT(p) FROM RecipePos AS p
WHERE p.recipeId = ?1"
I call this finder-method in a session-bean:
Collection col = home.findRecipe(recipeID);
But it fails with an error-message:
Log failed: CausedByException is:
Unexpected token in statement
[SELECT recipeId, recipePs, recipePosPK, side,
workDesc, machine, count, color, recipeDesc, comment)
FROM RECIPEPOS WHERE (recipeId = ? AND recipePs = ?)
OR (recipeId = ? AND recipePs = ?)
OR (recipeId = ? AND recipePs = ?)
OR (recipeId = ? AND recipePs = ?)
OR (recipeId = ? AND recipePs = ?)
...
OR (recipeId = ? AND recipePs = ?)
I have tried many EJB-QLs to read data from the table RecipePos, but the "Unexpected token"-error occurs in all of my EJB-QLs. Even "SELECT OBJECT(p) FROM RecipePos AS p" does not work. JBoss supplements every where-clause with the primary-key-fields "(recipeId = ? AND recipePs = ?)", and I don't know why.
EJB-QLs on other tables without a primary-key-compound-class works fine. For example, there is a table named RecipeHead with a simple Integer-ID as primary-key, and I can access this table through EJB-QL without problems. But RecipePos is my first table with a primary-key-compound-class, and there is no EJB-QL that will work with RecipePos.
Could anybody please help me, whether I have missed something to handle the access on tables with primary-key-compound-classes?
Regards,
Oliver