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,390 points
636 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,100 points
2,598 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,350 points
5,246 views
0 votes
1 answer

How to get a value from SQLite to convert it?

Server side: b = BtcConverter(force_decimal=True) p1btc = b.get_latest_price('USD') p1btcr = ...READ MORE

answered Sep 6, 2018 in Blockchain by digger
• 26,740 points
495 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
1,684 views
+1 vote
1 answer

How do i generate corda nodes keystores in dev mode?

In Corda, the node will look into ...READ MORE

answered Apr 11, 2018 in Blockchain by Perry
• 17,100 points
1,330 views
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
1,017 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP