将Jena属性表保存到TDB

时间:2015-09-05 13:47:22

标签: jena

当我尝试保存我的propertyTabelGraph时,我得到了 org.apache.jena.shared.AddDeniedExceptionenter例外。

performAdd类中的方法GraphBase抛出此异常:

/**
   Add a triple to the triple store. The default implementation throws an
   AddDeniedException; subclasses must override if they want to be able to add triples.
*/
@Override
public void performAdd( Triple t )
    { throw new AddDeniedException( "GraphBase::performAdd" ); }

调用此函数是因为我创建了一个继承的GraphPropertyTable 从GraphBase开始,没有像我预期的那样覆盖方法perfromAdd。

我不确定我现在该怎么办。 我怀疑我做错了什么,请帮我找出答案!

以下是重新创建错误的最小示例:

PropertyTable propertytable = new PropertyTableArrayImpl(2, 2);

Column alpha = propertytable.createColumn(NodeFactory.createLiteral("alpha"));
Column beta = propertytable.createColumn(NodeFactory.createLiteral("beta"));

Row one = propertytable.createRow(NodeFactory.createLiteral("one"));
Row two = propertytable.createRow(NodeFactory.createLiteral("two"));

propertytable.getRow(one.getRowKey()).setValue(alpha,NodeFactory.createLiteral("alpha-one"));
propertytable.getRow(one.getRowKey()).setValue(beta,NodeFactory.createLiteral("beta-two"));
propertytable.getRow(two.getRowKey()).setValue(alpha,NodeFactory.createLiteral("alpha-one"));
propertytable.getRow(two.getRowKey()).setValue(beta,NodeFactory.createLiteral("beta-two"));

GraphPropertyTable graph = new GraphPropertyTable(propertytable);
Model model = ModelFactory.createModelForGraph(graph); 
Dataset dataset = TDBFactory.createDataset("tdb/");
dataset.begin(ReadWrite.WRITE);
try {
    dataset.addNamedModel("www.example.org/model", model);
    dataset.commit();
} finally {
    dataset.end();
}

如何继续将我的属性表保留在磁盘上?

0 个答案:

没有答案