persistence@glassfish.java.net

RE: Problem using ManyToMany relationship

From: Romanowski, Tim <tim.romanowski_at_lmco.com>
Date: Wed, 28 Mar 2007 19:25:35 -0400

Ok, section 9.1.26, "FetchType fetch() default LAZY;". I didn't find that
particularly clear, but I do see that Basic is only applicable to a handful
of types. Chapter 9 of the spec is not something I had looked at before.

@ManyToMany(fetch=FetchType.EAGER)
   @JoinTable(name = "team_users",
        joinColumns = {_at_JoinColumn(name = "teamid", referencedColumnName =
"teamid")},
        inverseJoinColumns = {_at_JoinColumn(name = "username",
referencedColumnName = "username")})
    private java.util.Collection <com.my.persistence.entity.Users>
userCollection;

However, now I'm back to square one. I'm getting this name mismatch error.
I thought, "must be a mismatch with the database join table." But I look,
and my table is as expected:

Table: team_users
Columns: teamid, username


ANY access to the Team entity is causing the exception below. But I do have
some new info: a single call to an instance of Users' "getTeamCollection()"
generates the following exception:

Exception Description: The parameter name [username] in the query's
selection criteria does not match any parameter name defined in the query.
Query: ReadAllQuery(com.my.persistence.entity.Team)
        at
oracle.toplink.essentials.exceptions.QueryException.parameterNameMismatch(Qu
eryException.java:966)
        at
oracle.toplink.essentials.internal.expressions.ParameterExpression.getValue(
ParameterExpression.java:215)
        at
oracle.toplink.essentials.internal.databaseaccess.DatabaseCall.translate(Dat




However, if I instead access the Team entities "getUserCollection()," I get
a similar exception, but it says "Query:
ReadAllQuery(com.my.persistence.entity.Users)", and "The parameter name
[teamid] in the query's ..."




-----Original Message-----
From: Marina.Vatkina_at_Sun.COM [mailto:Marina.Vatkina_at_Sun.COM]
Sent: Wednesday, March 28, 2007 6:28 PM
To: persistence_at_glassfish.dev.java.net
Subject: Re: Problem using ManyToMany relationship

Did you look at attributes of the @ManyToMany annotation?

thanks,
-marina

Romanowski, Tim wrote:
> What else would I use? Isn't that how you define the fetch type?
>
> -----Original Message-----
> From: Marina.Vatkina_at_Sun.COM [mailto:Marina.Vatkina_at_Sun.COM]
> Sent: Wednesday, March 28, 2007 6:23 PM
> To: persistence_at_glassfish.dev.java.net
> Subject: Re: Problem using ManyToMany relationship
>
> Tim,
>
> Why did you use @Basic to do it?
>
> thanks,
> -marina
>