Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Join on concatenated columns
Join on concatenated columns [message #759870] Wed, 30 November 2011 12:19
Matti Hansson is currently offline Matti HanssonFriend
Messages: 68
Registered: July 2009
I have two tables in an Oracle database that I need to join, but the ID column in the one table equals two columns in the other table (FILE and NUMBER).

So table A have values FILE = "123-ABC/100" and NUMBER = 8 which would be joined by table B where ID = "123-ABC/100.8".

This SQL query works fine:

But I can't figure out how to do it with JPA. This is what I got at the moment:
public class A {
  private String id;

  @OneToMany(mappedBy = "a")
  private List<B> bs;

public class B {
  private String id;

  @JoinColumn(name = "ID", referencedColumnName = "FILE || '.' || NUMBER", insertable = false, updatable = false)
  private A a;

But this gives me a QueryException:
Exception [EclipseLink-6094] (Eclipse Persistence Services - 1.1.4.v20100812-r7860): org.eclipse.persistence.exceptions.QueryException
Exception Description: The parameter name [FILE || '.' || NUMBER] in the query's selection criteria does not match any parameter name defined in the query.
Query: ReadAllQuery(name="bs" referenceClass=B sql="SELECT B FROM B WHERE (ID = ?)")
  at org.eclipse.persistence.exceptions.QueryException.parameterNameMismatch(

Is there any way to solve this?

[Updated on: Wed, 30 November 2011 12:19]

Report message to a moderator

Previous Topic:has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass
Next Topic:Logging JPQL
Goto Forum:

Current Time: Fri Oct 09 03:19:57 GMT 2015

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

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