You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Michael Spiro <m....@dcs-caesar.de> on 2011/09/30 15:35:08 UTC

Join with a constant value

Hi,

 

I've got a problem with OpenJPA trying to make a join with a constant value.

 

According to the documentation, one can specify a constant value for a join
column, so that only records with this value in this column will be joined.
The constant value should be specified in the attribute
"referencedColumnName" of the @JoinColumn annotation. If the constant is a
string then its value should be enclosed first in single quotes and then in
double quotes like this:

 

@JoinColumn(name="table.column", referencedColumnName="'value'")

 

However, this declaration fails as I run my application. I debugged it and
found out something that looks like a possible bug. The method MappingInfo.
mergeJoinColumn() identifies the target of the join as a string constant if
its first character is a single quote (as it's described in the docs).
However, as this check takes place the value is already enclosed in one
extra pair of double quotes (in my example it's " "'value'"  ") and the
check fails.

 

I tried some different variations for the declaration like escaping the
quote sign with backslash or using double quotes, but this all doesn't help.
I'm running OpenJPA  2.1.0 under JDK 1.6.0_25 and Windows, the default
locale should be German. Is this a bug or maybe can I succeed with a
slightly different declaration?

 

As workaround I'll try to use a numeric constant, I hope this will work.

 

Kind regards,

Michael Spiro