我有2个viewObject,Strategy和Objective,两个表之间存在主/从关系。我还创建了两个视图对象之间的关联。
Strategy has primary key strgID, and strgName
并且Objective表具有
objvID as primary key, strgID as foreign key, and objvName
我将数据作为JSON对象获取,这里有一种策略,其下还有许多目标。我需要做的是在策略表中插入一条记录,获取由DBsequence自动生成的ID,并在插入目标表时将此ID用作外键。
我正在尝试使用ViewObjectImpl类以编程方式完成所有这些操作,这是我的代码:
AppModuleImpl am = null;
try {
am = (AppModuleImpl) Configuration.createRootApplicationModule(AM_DEF_NAME, AM_CONFIG_NAME);
BpmStrgViewImpl strgView = am.getBpmStrgView1(); // this the master viewobject
BpmObjvViewImpl objvView = am.getBpmObjvView1(); // this is the detail viewobject
//我遍历了JSON并获取了在主视图对象中插入行所需的值
Row row = strgView.createRow();
// the StrategyID is DB Sequence
row.setAttribute("StrgNameAr", json.get("name"));
strgView.insertRow(row);
现在masterViewObject有1行 现在我将插入详细信息viewObject Rows,这是代码 //虽然json具有目标行,但我将执行以下操作:
Row row = objvView.createRow(); // The Exceptions Happens at this line exactly
// object id is DB Sequence
row.setAttribute("strgID" , " the new generated sequence value from the master row " ) ;
row.setAttribute("objvName", "Value");
objvView.insertRow(row);
am.getTransaction().commit();
a
nd this is the Exception :
oracle.jbo.InvalidOwnerException: JBO-25030: Detail entity BpmObjv with row key oracle.jbo.Key[-2 ] cannot find or invalidate its owning entity.
at oracle.jbo.server.EntityImpl.internalCreate(EntityImpl.java:1585)
at oracle.jbo.server.EntityImpl.create(EntityImpl.java:977)
at oracle.jbo.server.EntityImpl.callCreate(EntityImpl.java:1412)
at oracle.jbo.server.ViewRowStorage.create(ViewRowStorage.java:1076)
at oracle.jbo.server.ViewRowImpl.create(ViewRowImpl.java:572)
at oracle.jbo.server.ViewRowImpl.callCreate(ViewRowImpl.java:610)
at oracle.jbo.server.ViewObjectImpl.createInstance(ViewObjectImpl.java:6343)
at oracle.jbo.server.QueryCollection.createRowWithEntities(QueryCollection.java:2202)
at oracle.jbo.server.ViewRowSetImpl.createRowWithEntities(ViewRowSetImpl.java:2830)
at oracle.jbo.server.ViewRowSetImpl.doCreateAndInitRow(ViewRowSetImpl.java:2876)
at oracle.jbo.server.EntityRowSetImpl.doCreateAndInitRow(EntityRowSetImpl.java:159)
at oracle.jbo.server.ViewRowSetImpl.createRow(ViewRowSetImpl.java:2852)
at model.BpmStrgImpl.create(BpmStrgImpl.java:390)
at oracle.jbo.server.EntityImpl.callCreate(EntityImpl.java:1412)
at oracle.jbo.server.ViewRowStorage.create(ViewRowStorage.java:1076)
at oracle.jbo.server.ViewRowImpl.create(ViewRowImpl.java:572)
at oracle.jbo.server.ViewRowImpl.callCreate(ViewRowImpl.java:610)
at oracle.jbo.server.ViewObjectImpl.createInstance(ViewObjectImpl.java:6343)
at oracle.jbo.server.QueryCollection.createRowWithEntities(QueryCollection.java:2202)
at oracle.jbo.server.ViewRowSetImpl.createRowWithEntities(ViewRowSetImpl.java:2830)
at oracle.jbo.server.ViewRowSetImpl.doCreateAndInitRow(ViewRowSetImpl.java:2876)
at oracle.jbo.server.ViewRowSetImpl.createRow(ViewRowSetImpl.java:2852)
at oracle.jbo.server.ViewObjectImpl.createRow(ViewObjectImpl.java:12867)
at model.MyClass.traverseTree(MyClass.java:23)
at model.MyClass.main(MyClass.java:71)
答案 0 :(得分:0)
我已经解决了以下问题:
am.getStrgObjvViewLink().setSource(strgView);
am.getStrgObjvViewLink().setDestination(objvView);