This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi, I have a table with a composite primary key of 2 fields. In my o/r mapping xml file, the class descriptor for this table contains 2 String fields (studioCode,ibcStudioName) , with the getter/setter methods. When I run the following statements, Criteria crit = new Criteria(); Criteria crit1 = new Criteria(); crit.addEqualTo("studioCode", codaStudioCode); crit1.addEqualTo("ibcStudioName", iBroadCastStudioName); crit.addAndCriteria(crit1); QueryByCriteria query = QueryFactory.newQuery(GenIBroadCastStudioName.class,crit); genIBroadCastStudioName = (GenIBroadCastStudioName) broker.getObjectByQuery(query); I encountered the following exception: org.apache.ojb.broker.accesslayer.RsIterator] ERROR: Error while iterate ResultSet for query org.apache.ojb.broker.accesslayer.RsQueryObject[query: Query from class sg.com.frontline.hbo.finance.components.general.GenIBroadCastStudioName where [studioCode = UNI, [ibcStudioName = UNI BS NAME 2]], class descriptor: sg.com.frontline.hbo.finance.components.general.GenIBroadCastStudioName] OJB needs at least one primary key attribute for class objectsRealClass=class sg.com.frontline.hbo.finance.components.general.GenIBroadCastStudioName, objectTopLevelClass=class sg.com.frontline.hbo.finance.components.general.GenIBroadCastStudioName org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: OJB needs at least one primary key attribute for class objectsRealClass=class sg.com.frontline.hbo.finance.components.general.GenIBroadCastStudioName, objectTopLevelClass=class sg.com.frontline.hbo.finance.components.general.GenIBroadCastStudioName at org.apache.ojb.broker.Identity.checkForPrimaryKeys(Unknown Source) at org.apache.ojb.broker.Identity.<init>(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.getIdentityFromResultSet(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at mytutorial.OneToManyRetrieval.getGenIBroadCastStudioName(OneToManyRetrieval.java:358) at mytutorial.OneToManyRetrieval.main(OneToManyRetrieval.java:490) What went wrong? Appreciate your valuable advice. Thanks!
Can you post the relevent bits of the repository mapping (repository_user.xml typically) and verify the Class/field information? -Brian ps: you are far more likely to get answers to questions like this on the OJB user's list =)