Thanks crispyoz. 

I think I've whittled this down to a decent test case. The issue appears to
be: 

If a subclass of an entity using SINGLE_TABLE inheritance and which
specifies @SecondaryTable(SEC_TBL), contains a
@Column(table="SEC_TBL",name="...") then a find(subclass.class,pk) results
in 

'INNER JOIN PRI_TABLE on PRI_TABLE.id = subclass_ID' 

where 'subclass_ID' is not in the table, and should simply be 'ID'.

For example:

@Entity
@Table(name="CUSTOMERTYPE")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@SecondaryTable(name="CUSTOMERDATA",pkJoinColumns = @PrimaryKeyJoinColumn
                (name="ID", referencedColumnName="ID"))
@DiscriminatorColumn(name="ROLE",length=4)
public class CustomerClass extends EntityImpl implements Serializable {
        @Id
        @Column(name="ID")
        protected String id;
}
//***************************
@Entity
@DiscriminatorValue(value="0010")
public class ValuedCustomerClass extends Customer implements Serializable  {
        @Column(table="CUSTOMERDATA",name="NAME")
        private String name;
}

find(Customer.class,aValuedCustomerPK)

<openjpa-1.2.2-SNAPSHOT-r422266:821449 nonfatal general error> 
org.apache.openjpa.persistence.PersistenceException: DB2 SQL error: SQLCODE:
-206, SQLSTATE: 42703, 
SQLERRMC: T1.CUSTOMER_ID  
SELECT t0.ROLE, t1.NAME 
FROM CUSTOMERTYPE t0 
INNER JOIN CUSTOMERDATA t1 ON t0.ID = t1.CUSTOMERCLASS_ID   <<< should be
t1.ID



-- 
View this message in context: 
http://n2.nabble.com/JPA-adding-class-name-to-join-column-name-tp4630454p4640216.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to