When using both gRPC and Spring Boot with JPA, I find myself with the situation where I’m forced to write duplicate Java data transfer objects to represent the same thing, and I’m wondering if there is a better way.
So let’s say you have this tika.proto file:
message SaveFetcherRequest {
string fetcher_id = 1;
string plugin_id = 2;
string fetcher_config_json = 3;
}
This will generate a org.apache.tika.SaveFetcherRequest
java stub object.
But then JPA uses an Repository that writes from an Entity object.
@Entity
public class Fetcher {
@Id
String fetcher_id;
String plugin_id2;
String fetcher_config_json;
}
I very much wanted to just use the auto-generated java class without having to re-create that class by hand.
Can such a thing be done?
2