Protocol Buffers/Protobuf Entity
Protocol Buffers
Current ApiHug entity and column syntax for protobuf-based database modeling.
ApiHug maps domain messages to database structures through hope.persistence.table and hope.persistence.column.
import "apihug/protobuf/domain/annotations.proto";
That import registers:
(hope.persistence.table) on google.protobuf.MessageOptions(hope.persistence.column) on google.protobuf.FieldOptionsUse scalar booleans and scalar numeric fields. Do not use nested wrapper objects for properties like length, precision, or scale.
message Account {
option (hope.persistence.table) = {
name: "ACCOUNT";
description: "Account table";
wires: [IDENTIFIABLE, AUDITABLE];
};
string user_name = 1 [(hope.persistence.column) = {
name: "MY_USER_NAME";
description: "Name of the account";
nullable: false;
updatable: false;
length: 32;
type: VARCHAR;
}];
}
Project module {module}-proto can still tune persistence defaults in src/resources/hope-wire.json:
{
"persistence": {
"identifyType": "LONG",
"tenantType": "LONG",
"format": "CAMEL",
"upper": "UPPER"
}
}
format: "DEFAULT" keeps the framework default naming conventionformat: "CAMEL" keeps camelCase field namingformat: "SNAKE" forces snake_case field namingupper: "DEFAULT" keeps the framework default case transformationupper: "UPPER" converts generated column names to uppercaseupper: "LOWER" converts generated column names to lowercaseupper: "CAPITALIZE" converts generated column names to capitalized formIf the proto explicitly sets name, that manual column name still wins.
Table from persistence.proto covers:
name, catalog, schema, descriptionunique_constraintsindexesviewswiresliquibaseColumn covers:
nullable, unique, insertable, updatable, searchable, sortablelength, precision, scaletype, enum_typeid, generated_valuetransient, default_value, column_definition, table