I have created Java Chaincode and deployed it on Fabric 2.2 network. Everything seems to be working but when I do any query from the ledger, I am getting blank JSON Response. I don't see any issue in logs so seems like everything is working but somehow response is blank.
@Transaction()
public Car queryCarById(final Context ctx, final String id) {
ChaincodeStub stub = ctx.getStub();
String CarState = stub.getStringState(id);
if (CarState.isEmpty()) {
String errorMessage = String.format("Car %s does not exist", id);
System.out.println(errorMessage);
throw new ChaincodeException(errorMessage, CarTransferErrors.Car_NOT_FOUND.toString());
}
Car Car = genson.deserialize(CarState, Car.class);
System.out.println(Car);
return Car;
}
package Cartransfer;
import com.owlike.genson.annotation.JsonProperty;
import org.hyperledger.fabric.contract.annotation.DataType;
import org.hyperledger.fabric.contract.annotation.Property;
@DataType()
public final class Car {
@Property()
private final String id;
@Property()
private final String name;
@Property()
private final String area;
@Property()
private final String ownerName;
@Property()
private final String value;
public String getid() {
return id;
}
public String getname() {
return name;
}
public String getarea() {
return area;
}
public String getownerName() {
return ownerName;
}
public String getvalue() {
return value;
}
public Car(@JsonProperty("id") final String id, @JsonProperty("name") final String name,
@JsonProperty("area") final String area, @JsonProperty("ownerName") final String ownerName,
@JsonProperty("value") final String value) {
this.id = id;
this.name = name;
this.area = area;
this.ownerName = ownerName;this.value= value;}}