EJBQL: comparing object-parameter and relation-field gives s
kutter Aug 4, 2003 8:57 AMHelp Needed
(I am working with an out-of-the box configuration,
based on the examples in the buy-documentation
for CMP2.0, JBoss 3.2.1.)
I am trying to make an EJBQL-finder method,
which takes an object as argument, and then
compares this to an object obtained by using
a CMR-relation.
I think someone may give me a hint, without going
trough all the code. If not, I will build it into the
as-is gangster-example and post the full code.
Problem Description:
I have the following bean, two versions of
a finder method findAD03, findAD04, and a
CMR-relation field userHoldingAd. For findAD03 it
works, for findAD04 I get an error:
import interfaces.UserEntityLocal;
...
* @ejb.finder
* signature = "java.util.Collection findAD03(interfaces.UserEntityLocal uid1, interfaces.UserEntityLocal uid2)"
* query = "SELECT OBJECT(g) FROM affinityData g, userEntity u WHERE u = ?1 "
*
* @ejb.finder
* signature = "java.util.Collection findAD04(interfaces.UserEntityLocal uid1, interfaces.UserEntityLocal uid2)"
* query = "SELECT OBJECT(g) FROM affinityData g WHERE g.userHoldingAd = ?1 "
*
*/
public abstract class AffinityDataBean implements EntityBean{
...
/**
* @return
* @ejb.relation
* name = "Users-Holding-ADs"
* role-name = "ad-hold-by-userEntity"
* cascade-delete = "yes"
* @jboss.relation
* related-pk-field = "userEntityId"
* fk-column = "userHoldingAd"
*
* @ejb.persistence
* column-name = "userHoldingAd"
* @ejb.interface-method
*/
public abstract UserEntityLocal getUserHoldingAd();
public abstract void setUserHoldingAd(UserEntityLocal org);
...
}
I wrote a test case, where I give the two user entities, and get the collections:
UserEntityLocal yojimbo =
userEntityHome.findByPrimaryKey(YOJIMBO);
UserEntityLocal takeshi =
userEntityHome.findByPrimaryKey(TAKESHI);
Collection all =
affinityDataHome.findAD03(yojimbo, takeshi);
With findAD03 it works, thus I provide two good arguments, and, althoug the code does not make something useful,
it seems I can compare u with the parameter ?1
Now, if I replace find AD03 with findAD04, I compare g.userHoldingAd with ?1
I have tested the CMR field userHoldinAd in other routines. What I get for findAD04 (but not for findAD03) is the following error:
testUsersAD(test.CrimePortalTest): Find failed: java.sql.SQLException: Wrong data type: For string: "[B@987e1e" in statement [SELECT t0_g.affinityDataId FROM AFFINITYDATA t0_g, USERENTITY t1_g_userHoldingAd WHERE ((t1_g_userHoldingAd.id=0)) AND (t0_g.userHoldingAd=t1_g_userHoldingAd.id)]
If someone could help me would be great!