openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Spiro (Commented) (JIRA)" <>
Subject [jira] [Commented] (OPENJPA-2054) Constant join fails
Date Fri, 30 Sep 2011 16:36:45 GMT


Michael Spiro commented on OPENJPA-2054:

Possible explanation:

The bug is in the class org.apache.openjpa.persistence.jdbc.AnnotationPersistenceMappingParser
in the line 1717 (OpenJPA version 2.1.0):

     * Create a new schema column with information from the given annotation.
    private Column newColumn(JoinColumn join) {
        Column col = new Column();
        if (!StringUtils.isEmpty(
            col.setIdentifier(DBIdentifier.newColumn(, delimit()));
        if (!StringUtils.isEmpty(join.columnDefinition()))

        if (!StringUtils.isEmpty(join.referencedColumnName()))
            col.setTargetIdentifier(DBIdentifier.newColumn(join.referencedColumnName(), delimit()));
        col.setFlag(Column.FLAG_UNINSERTABLE, !join.insertable());
        col.setFlag(Column.FLAG_UNUPDATABLE, !join.updatable());
        return col;

If the attribute referencedColumnName is not empty it’s just assumed without any check to
be a column reference and is not supposed to be a constant. The DBIdentifier for this element
is then created with the type COLUMN. If this would be CONSTANT, then the method DBIdentifier.setName(String
name, boolean delimit) wouldn’t add delimiters and everything would be probably correct.
But it’s considered to be a COLUMN. The solution would be to add the check for a constant
value before this line:

col.setTargetIdentifier(DBIdentifier.newColumn(join.referencedColumnName(), delimit()));

> Constant join fails
> -------------------
>                 Key: OPENJPA-2054
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.1.0
>            Reporter: Michael Spiro
>              Labels: Constant, join
> According to the documentation (Part 3, chapter 7, paragraph 6), join criteria can be
defined so that a column in the source or target table must have some constant value. 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'")
> A numeric constant value needs just a single pair of double quotes:
> @JoinColumn(name="table.column", referencedColumnName="2")
> However a practical test shows that both options produce an error.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message