openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tradingfours <nab...@reider.net>
Subject RE: JPA adding class name to join column name
Date Sat, 27 Feb 2010 00:25:16 GMT

typos corrected:

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 = SEC_TBL.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 CustomerClass implements
Serializable  {
	@Column(table="CUSTOMERDATA", name="NAME")
	private String name;
}

find(CustomerClass.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.VALUEDCUSTOMERCLASS_ID
SELECT t0.ROLE, t1.NAME 
FROM CUSTOMERTYPE t0 
INNER JOIN CUSTOMERDATA t1 ON t0.ID = t1.VALUEDCUSTOMERCLASS_ID    <<<
should be t1.ID
-- 
View this message in context: http://n2.nabble.com/JPA-adding-class-name-to-join-column-name-tp4630454p4642827.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message