How to search inside List for a specific value?

0 votes

I'm trying to search value inside Corda unconsumed states on a collection Field.

Following is the string field I am using -

Field uniqueAttributeName = MySchema.PersistentIOU.class.getDeclaredField("fieldname");
        CriteriaExpression uniqueAttributeEXpression = Builder.equal(uniqueAttributeName, "valueToSearch");

        QueryCriteria customCriteria = new QueryCriteria.VaultCustomQueryCriteria(uniqueAttributeEXpression);
        result = rpcOps.vaultQueryByCriteria(customCriteria, MyState.class).getStates();

The above code worked fine when fieldname is String but I have another field which is List and I'm not sure how to search inside List for a specific value. Please help.

Jun 27, 2018 in Blockchain by sabby
• 4,350 points
91 views

1 answer to this question.

0 votes

You can amend your ORM wrapper such that you have a parent - child relationship between the state and the list of fields you want to have in that list. Once this is done, the JDBC connection available to you to query against the child state and then use the relationship to the parent to get the Corda state.

Hope this helps :)

answered Jun 27, 2018 by Christine
• 15,790 points

Related Questions In Blockchain

+1 vote
2 answers

How to return value from a chaincode in Hyperledger Fabric?

Hyperledger Fabric supports only 2 types of ...READ MORE

answered Jun 13, 2018 in Blockchain by Perry
• 17,020 points
864 views
0 votes
1 answer
0 votes
1 answer

How to solve “insufficient funds for gas * price + value” error?

Change the following line Credentials credentials = Credentials.create(firstAccount); To ...READ MORE

answered Aug 1, 2018 in Blockchain by slayer
• 29,170 points
381 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
155 views
+1 vote
1 answer
0 votes
1 answer

How to explore and analyze the data inside a Hyperledger Blockchain network?

In Hyperledger Composer, you have all the ...READ MORE

answered Aug 10, 2018 in Blockchain by Christine
• 15,790 points
121 views
0 votes
1 answer