{"id":15019319,"url":"https://github.com/yuanwenqing/protobuf4j","last_synced_at":"2026-02-05T23:31:25.884Z","repository":{"id":57743945,"uuid":"138725862","full_name":"YuanWenqing/protobuf4j","owner":"YuanWenqing","description":"A Facility Framework to Develop with Google Protobuf","archived":false,"fork":false,"pushed_at":"2020-09-19T09:56:54.000Z","size":626,"stargazers_count":1,"open_issues_count":13,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T18:15:07.629Z","etag":null,"topics":["dao","framework","orm","protobuf","protobuf3","spring-boot","sql"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YuanWenqing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-26T11:02:40.000Z","updated_at":"2024-03-13T08:01:06.000Z","dependencies_parsed_at":"2022-08-31T08:41:04.333Z","dependency_job_id":null,"html_url":"https://github.com/YuanWenqing/protobuf4j","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YuanWenqing%2Fprotobuf4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YuanWenqing%2Fprotobuf4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YuanWenqing%2Fprotobuf4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YuanWenqing%2Fprotobuf4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YuanWenqing","download_url":"https://codeload.github.com/YuanWenqing/protobuf4j/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135125,"owners_count":20889420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dao","framework","orm","protobuf","protobuf3","spring-boot","sql"],"created_at":"2024-09-24T19:53:19.775Z","updated_at":"2026-02-05T23:31:25.852Z","avatar_url":"https://github.com/YuanWenqing.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Protobuf4j\n\n## Introduction\n\nA Facility framework to develop with Google Protobuf, including:\n\n* Utils to handle Protobuf messages and enums\n* ORM-based DAO for storing Protobuf Message in MySQL\n* Some supports with Spring and SpringBoot\n\n## Modules\n\n* `protobuf4j-core`: helper class for Protobuf Message and Enum, codec class for Message.\n* `protobuf4j-sql`: abstraction for SQL fragment and statement.\n* `protobuf4j-orm`: basic ORM-like DAO framework utilizing `protobuf4j-sql`\n* `protobuf4j-orm-starter`: springboot starter for `protobuf4j-orm`, including autoconfiguration and jdbc injection\n* `protobuf4j-spring`: some extensions for Protobuf to integrate with spring\n\n## ORM Usage\n\n### Gradle\n\n~~~groovy\nimplementation(\"xyz.codemeans.protobuf4j:protobuf4j-orm-starter:$protobuf4jVersion\")\n~~~\n\nThe latest version can be found in maven central repository.\n\n### Properties\n\n~~~properties\nprotobuf4j.datasource.auto-enable=\u003cif-auto-configuration-enalbed:default true\u003e\n~~~\n\n### Java\n\nExample Code: [example](example/src/main)\n\ninterface\n\n~~~java\npublic interface ExampleDao extends IPrimaryKeyMessageDao\u003cLong, Example\u003e {\n}\n~~~\n\nimpl\n\n~~~java\n@Repository\npublic class ExampleDaoImpl extends PrimaryKeyProtoMessageDao\u003cLong, Example\u003e implements ExampleDao {\n  public ExampleDaoImpl() {\n    super(Example.class, ExampleNaming.ID);\n  }\n}\n~~~\n\n### CRUD\n\n~~~java\n@Autowired\nExampleDao exampleDao;\n\npublic Example createExample(Example example) {\n  long id = exampleDao.insertReturnKey(example).longValue();\n  return exampleDao.selectOneByPrimaryKey(id);\n}\n\npublic Example getExample(long id) {\n  return exampleDao.selectOneByPrimaryKey(id);\n  // or\n  //return exampleDao.selectOneByCond(FieldAndValue.eq(ExampleNaming.ID, id));\n}\n\npublic Example updateExample(Example newValue, Example oldValue) {\n  exampleDao.updateMessageByPrimaryKey(newValue, oldValue);\n  return exampleDao.selectOneByPrimaryKey(newValue.getId());\n}\n\npublic void deleteExample(long id) {\n  exampleDao.deleteByPrimaryKey(id);\n}\n\n// complex conditions and pagination\npublic List\u003cExample\u003e listExamples(WhereClause where) {\n  return exampleDao.selectByWhere(where);\n}\n\npublic Map\u003cLong, Example\u003e getExamples(Collection\u003cLong\u003e ids) {\n  return exampleDao.selectMultiByPrimaryKey(ids);\n}\n~~~\n\n## SQL Usage\n\n~~~java\n// condition\nList\u003cIExpression\u003e conds = Lists.newArrayList();\nconds.add(FieldAndValue.like(ExampleNaming.NAME, SqlUtil.likePrefix(prefix)));\nconds.add(FieldAndValue.gte(ExampleNaming.ID, beg));\nconds.add(FieldAndValue.lt(ExampleNaming.ID, end));\nIExpression allAndCond = LogicalExpr.and(conds));\n\n// pagination\nPaginationClause.newBuilder(limit).buildByOffset(offset);\nPaginationClause.newBuilder(limit).buildByPageNo(pn)\n\n// select specified columns\nSelectClause selectClause = new SelectClause();\nselectClause.select(ExampleNaming.NAME);\nFromClause fromClause = QueryCreator.fromType(Example.class);\nSelectSql sql = new SelectSql(selectClause, fromClause);\nexampleDao.doSelect(sql, new SingleColumnRowMapper\u003c\u003e(String.class));\n\n// update whole message with different fields\nexampleDao.updateMessageByPrimaryKey(newValue, oldValue);\n\n~~~\n\n\n\n## Reference\n\n* `naming`: a Protobuf codegen plugin to generate *Naming class containing field naming constatns, see \u003chttps://github.com/YuanWenqing/protoplugin\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanwenqing%2Fprotobuf4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuanwenqing%2Fprotobuf4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanwenqing%2Fprotobuf4j/lists"}