Persisting Protobuf messages to Database

Viewed 13016

What is the right way to persist data defined using protobuf3. I am using golang and Java, both place with support of ORMs. In java with Hibernate and golang with gorm. Both place i need to convert the Generated code to corresponding Entity model. I feel that is more pain full to maintain same object structure in order to be understandable by ORM. Is there any Database which i can use along with protobuf objects as is. Or i can define the relations between objects in the protobuf itself.

Any helps really appreciated.

4 Answers

Although this question is quite old, things have happened since then and the FoundationDB Record Layer, released by Apple in 2018, stores Protocol Buffer natively.

In Go, I don't know about gorm, but it seems that with Ent (a competing ORM) Protobufs can be deserialized into exactly the same objects which are used for DB tables/relations. Ent's official tutorial for that.

The caveat is that you specify your Protobuf with Ent's Golang structures, not via the standard proto3 language.

Related