1 of 1 people found this helpful
the definitive source of metadata is the protobuf definition file, not the java or the cpp class you are using to represent the data. The marshallers (eg PersonMarshaller) are responsible for mapping your data (Person class) to a Person message type, the one defined in the protobuf file. The mapping is done in the readFrom/writeTo methods of the marshaller. Trying to do some guessing based on Java reflection is a bit like trying to guess what readFrom/writeTo methods are doing - flawed in most cases, although it can work if you follow some rigorous mapping conventions. But I would not recommend going the reflection route. It's easier to obtain the metadata from the proto file. You don't need to actually parse it yourself, it's parsed already. ProtoStreamMarshaller.getSerializationContext(cacheManager).getMessageDescriptor("quickstart.Person") will give you a com.google.protobuf.Descriptors.Descriptor for the quickstart.Person protobuf type, which has all you need (see here https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/Descriptors.Descriptor)
Query query = qf.from(Person.class)
"phone.number" refers to the protobuf property, not the java property. The java property could have been named a bit differently, the only one who has toe deal with the mapping is the marshaller.
This is great. Thanks.
This will definitely simplify the task of mapping it to a relational structure.
Do you have a data type mapping matrix between the protobuf types and java object types that you can point me to?
I think I found it, the FieldDescriptor.getJavaType(). Sorry, I should have looked deeper first before asking. But you never know how deep you have to look.