You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Enrico Goosen <eg...@metropolitan.co.za> on 2008/06/14 15:08:44 UTC

OpenJPA-1.1.0/Spring-2.x JPATemplate.find not working for composite PK

I'm not sure if I should post this here on in the Spring forum, but here
goes...

This method doesn't work:
public T getObjectByID(PK id) {
	return (T) getJpaTemplate().find(type, id);
}

I'm trying to find an entity using a composite PK:
TblPdtbnfPK pk = new TblPdtbnfPK();
pk.pdtbnfId = tblPdtbnf.getPdtbnfId();
pk.scmpdtId = tblPdtbnf.getScmpdtId();
tblPdtbnf = getPdtbnfDAO().getObjectByID(pk); //this returns null

When I check the debug SQL output, the select statement is only finding on
one of the fields, not on both PK fields.
eg. select .... from TBL_PDTBNF a where a.SCMPDT_ID = ? //leaving out the
second field PDTBNF_ID 

If I test without Spring, it works.
-- 
View this message in context: http://www.nabble.com/OpenJPA-1.1.0-Spring-2.x-JPATemplate.find-not-working-for-composite-PK-tp17839302p17839302.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.