Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OJB error

 
David Tan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Brian McCallister
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 =)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic