Hibernate criteria problem with composite key?

Not sure about your specific class structure but try to add id this way instead of separate criteria.

Up vote 0 down vote favorite share g+ share fb share tw.

I got this hibernate mapping: This is a simple composite key mapping with a relation to table productCoverage and a composite key relation to productterm. Now the problem comes in my search function: public CoverageTerm getCoverageTermFromProductTermCoverage(ProductTerm productTerm, ProductCoverage productCoverage) { Criteria critCt = getSession(). CreateCriteria(CoverageTerm.

Class); Criteria critCtId = critCt. CreateCriteria("id"); critCtId. Add(Restrictions.

Eq("productTerm", productTerm)); critCtId. Add(Restrictions. Eq("productCoverage", productCoverage)); return (CoverageTerm) critCt.uniqueResult(); } This should let me make a subcriteria on "id" (which is the primary key, CoverageTermPK) and add restrictions on it, but when I run it I get the error message: org.springframework.web.util.

NestedServletException: Request processing failed; nested exception is org.hibernate. QueryException: could not resolve property: productTerm of: CoverageTerm This feels strange, shouldn't it get the CoverageTermPK there? If I try with a subcriteria on the "data" property the criterias work, I just don't seem to be able to get the PK on the "id" subcriteria.

Any ideas as to why this is happening? Java hibernate spring composite link|improve this question asked May 25 '11 at 7:19Dytut434.

Not sure about your specific class structure but try to add id this way instead of separate criteria: Restrictions. Eq("id. ProductTerm", productTerm); Restrictions.

Eq("id. ProductCoverage", productCoverage).

That did it, thank you very much! – Dytut May 25 '11 at 7:42.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions