wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes OJB error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "OJB error" Watch "OJB error" New topic
Author

OJB error

David Tan
Greenhorn

Joined: Sep 30, 2002
Posts: 9
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

Joined: Dec 03, 2002
Posts: 19
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 =)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OJB error