Error While Fetching Data from Corda Custom Tables -


how fetch data corda custom tables? sample code follows :-

api layer -- getious() method  {     field attributevalue=iouschemav1.persistentiou.class.getdeclaredfield("value");     criteriaexpression currencyindex = builder.equal(attributevalue, "12");     querycriteria.vaultcustomquerycriteria criteria = new      querycriteria.vaultcustomquerycriteria(currencyindex);     vaultstates = services.vaultquerybycriteria(criteria,ioustate.class); } 
  1. in exampleplugin added below code schema registration

    public class exampleplugin extends cordapluginregistry implements  webserverpluginregistry { @notnull @override public set<mappedschema> getrequiredschemas() {     set<mappedschema> requiredschemas = new hashset<>();     requiredschemas.add(new iouschemav1());     return requiredschemas; } 

    }

  2. my schema classes ---

    public final class iouschema {  }   @cordaserializable public class iouschemav1 extends mappedschema  { public iouschemav1() {     super(iouschema.class, 1, immutablelist.of(persistentiou.class)); }  @entity @table(name = "iou_states") public static class persistentiou extends persistentstate { @column(name = "sender_name") private final string sendername; @column(name = "recipient_name") private final string recipientname; @column(name = "value") private final int value;   public persistentiou(string sendername, string recipientname, int value) {     this.sendername = sendername;     this.recipientname = recipientname;     this.value = value; }  public string getsendername() {     return sendername; }  public string getrecipientname() {     return recipientname; }  public int getvalue() {     return value; } 

    } }

  3. my state has :-

    public class ioustate implements linearstate, queryablestate  {  --- code goes here , below methods well.--- @override public persistentstate generatemappedobject(mappedschema schema) { if (schema instanceof iouschemav1) {     return new iouschemav1.persistentiou(             this.sender.getname().tostring(),             this.recipient.getname().tostring(),             this.iou.getvalue()); } else {     throw new illegalargumentexception("unrecognised schema $schema"); } }  @override public iterable<mappedschema> supportedschemas() { return immutablelist.of(new iouschemav1()); } } 

but time getting below exception.

caused by: net.corda.core.node.services.vaultqueryexception:

please register entity 'com.example.schema.iouschemav1' class in cordapp's cordapluginregistry configuration (requiredschemas attribute) , ensure have declared (in supportedschemas()) , mapped (in generatemappedobject()) schema in associated contract state's queryablestate interface implementation.

can please resolve this.

try deleting implements webserverpluginregistry plugin declaration.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -