Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Embeddable with ManyToMany relationship(Embeddable with ManyToMany relationship)
Embeddable with ManyToMany relationship [message #658446] Tue, 08 March 2011 14:52 Go to next message
No real name is currently offline No real nameFriend
Messages: 1
Registered: March 2011
Junior Member
I have an Entity (Foo) that contains an Embeddable (FooBar) which has a ManyToMany relationship to another Entity (Bar) (code below). When I run a query

select f, f.fooBar from Foo f

I get an exception

Exception [EclipseLink-6094] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.QueryException
Exception Description: The parameter name [ID] in the query's selection criteria does not match any parameter name defined in the query.

More stack trace below.

Is there something wrong with my entities or with my query?

Using EclipseLink 2.2.0 on PostgreSQL 8.4

- Jon



@Entity
public class Foo {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;

@Embedded
private FooBar fooBar;

public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public FooBar getFooBar() { return fooBar; }
public void setFooBar(FooBar fooBar) { this.fooBar = fooBar; }
}

@Embeddable
public class FooBar {

@ManyToMany(fetch=FetchType.EAGER)
private Set<Bar> bars;

public Set<Bar> getBars() { return bars; }
public void setBars(Set<Bar> bars) { this.bars = bars; }
}


@Entity
public class Bar {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
private String name;

public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}

Local Exception Stack:
Exception [EclipseLink-6094] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.QueryException
Exception Description: The parameter name [ID] in the query's selection criteria does not match any parameter name defined in the query.
Query: ReadAllQuery(name="bars" referenceClass=Bar sql="SELECT t1.ID, t1.NAME FROM FOO_BAR t0, BAR t1 WHERE ((t0.Foo_ID = ?) AND (t1.ID = t0.bars_ID))")
at org.eclipse.persistence.exceptions.QueryException.parameterN ameMismatch(QueryException.java:1050)
at org.eclipse.persistence.internal.expressions.ParameterExpres sion.getValue(ParameterExpression.java:246)
at org.eclipse.persistence.internal.databaseaccess.DatabaseCall .translate(DatabaseCall.java:951)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.executeCall(DatasourceCallQueryMechanism.java:206)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.executeCall(DatasourceCallQueryMechanism.java:193)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.executeSelectCall(DatasourceCallQueryMechanism.jav a:264)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.selectAllRows(DatasourceCallQueryMechanism.java:64 7)
at org.eclipse.persistence.internal.queries.ExpressionQueryMech anism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2 558)
at org.eclipse.persistence.internal.queries.ExpressionQueryMech anism.selectAllRows(ExpressionQueryMechanism.java:2517)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLe velReadQuery(ReadAllQuery.java:410)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute DatabaseQuery(ObjectLevelReadQuery.java:1080)
at org.eclipse.persistence.queries.DatabaseQuery.execute(Databa seQuery.java:808)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute (ObjectLevelReadQuery.java:1040)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAll Query.java:383)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute InUnitOfWork(ObjectLevelReadQuery.java:1126)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.int ernalExecuteQuery(UnitOfWorkImpl.java:2842)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1521)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1503)
at org.eclipse.persistence.internal.indirection.NoIndirectionPo licy.valueFromQuery(NoIndirectionPolicy.java:323)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.val ueFromRowInternal(ForeignReferenceMapping.java:2061)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.val ueFromRow(ForeignReferenceMapping.java:1950)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.bui ldCloneFromRow(ForeignReferenceMapping.java:274)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.b uildAttributesIntoWorkingCopyClone(ObjectBuilder.java:1415)
at org.eclipse.persistence.mappings.AggregateObjectMapping.buil dAggregateFromRow(AggregateObjectMapping.java:360)
at org.eclipse.persistence.queries.ReportQueryResult.processIte m(ReportQueryResult.java:199)
at org.eclipse.persistence.queries.ReportQueryResult.buildResul t(ReportQueryResult.java:141)
at org.eclipse.persistence.queries.ReportQueryResult.<init>(ReportQueryResult.java:76)
at org.eclipse.persistence.queries.ReportQuery.buildObject(Repo rtQuery.java:594)
at org.eclipse.persistence.queries.ReportQuery.buildObjects(Rep ortQuery.java:645)
at org.eclipse.persistence.queries.ReportQuery.executeDatabaseQ uery(ReportQuery.java:841)
at org.eclipse.persistence.queries.DatabaseQuery.execute(Databa seQuery.java:808)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute (ObjectLevelReadQuery.java:1040)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAll Query.java:383)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute InUnitOfWork(ObjectLevelReadQuery.java:1126)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.int ernalExecuteQuery(UnitOfWorkImpl.java:2842)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1521)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1503)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1477)
Re: Embeddable with ManyToMany relationship [message #658685 is a reply to message #658446] Wed, 09 March 2011 13:20 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Hello,

Looks like a bug when selecting the embeddable, please file a bug for it. The workaround is to not directly select the embeddable when it has a ManyToMany relationship, and instead access it from the returned Foo object, as the query is returning it anyway.

Best Regards,
Chris
Previous Topic:Generating DDL scripts with maven?
Next Topic:NoSuchMethod - sufix _vh
Goto Forum:
  


Current Time: Mon Nov 24 18:02:38 GMT 2014

Powered by FUDForum. Page generated in 0.01704 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software