{"id":15495044,"url":"https://github.com/hectorbst/jsonschema2pojo-spring-data-couchbase","last_synced_at":"2026-05-05T00:38:45.454Z","repository":{"id":57731156,"uuid":"297454846","full_name":"HectorBst/jsonschema2pojo-spring-data-couchbase","owner":"HectorBst","description":"jsonschema2pojo extension to generate Spring Data Couchbase specific POJOs","archived":false,"fork":false,"pushed_at":"2021-01-26T21:07:53.000Z","size":104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-19T12:16:17.992Z","etag":null,"topics":["couchbase","couchbase-document","generator","java","json","json-properties","jsonschema","jsonschema2pojo","pojo","schema","spring","spring-data","spring-data-couchbase","springdata"],"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/HectorBst.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":"2020-09-21T20:34:37.000Z","updated_at":"2021-01-26T21:07:55.000Z","dependencies_parsed_at":"2022-09-26T22:01:48.829Z","dependency_job_id":null,"html_url":"https://github.com/HectorBst/jsonschema2pojo-spring-data-couchbase","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HectorBst%2Fjsonschema2pojo-spring-data-couchbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HectorBst%2Fjsonschema2pojo-spring-data-couchbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HectorBst%2Fjsonschema2pojo-spring-data-couchbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HectorBst%2Fjsonschema2pojo-spring-data-couchbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HectorBst","download_url":"https://codeload.github.com/HectorBst/jsonschema2pojo-spring-data-couchbase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246068302,"owners_count":20718503,"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":["couchbase","couchbase-document","generator","java","json","json-properties","jsonschema","jsonschema2pojo","pojo","schema","spring","spring-data","spring-data-couchbase","springdata"],"created_at":"2024-10-02T08:15:54.007Z","updated_at":"2026-05-05T00:38:45.417Z","avatar_url":"https://github.com/HectorBst.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build](https://img.shields.io/github/workflow/status/hectorbst/jsonschema2pojo-spring-data-couchbase/Build?label=Build)](https://github.com/HectorBst/jsonschema2pojo-spring-data-couchbase/actions?query=workflow%3ABuild)\n[![Coverage](https://img.shields.io/sonar/coverage/HectorBst_jsonschema2pojo-spring-data-couchbase?server=https%3A%2F%2Fsonarcloud.io\u0026label=Coverage)](https://sonarcloud.io/dashboard?id=HectorBst_jsonschema2pojo-spring-data-couchbase)\n[![Violations](https://img.shields.io/sonar/violations/HectorBst_jsonschema2pojo-spring-data-couchbase?server=https%3A%2F%2Fsonarcloud.io\u0026label=Violations)](https://sonarcloud.io/dashboard?id=HectorBst_jsonschema2pojo-spring-data-couchbase)\n[![Maven Central](https://img.shields.io/maven-central/v/dev.hctbst/jsonschema2pojo-spring-data-couchbase?label=Maven%20Central)](https://search.maven.org/artifact/dev.hctbst/jsonschema2pojo-spring-data-couchbase)\n[![License](https://img.shields.io/github/license/hectorbst/jsonschema2pojo-spring-data-couchbase?label=License)](LICENSE)\n\n# jsonschema2pojo-spring-data-couchbase\n\nThis project is a [*jsonschema2pojo*](https://github.com/joelittlejohn/jsonschema2pojo) extension dedicated to\n[*Spring Data Couchbase*](https://docs.spring.io/spring-data/couchbase/docs/current/reference/html) entities generation.\n\n## Features\n\n### Couchbase document\n\nAt the schema of an object level, it is possible to define a POJO as being a Couchbase document using the custom JSON\nproperty `x-cb-document`.\n\n* If missing, the value of this property is `true` if the schema is at root or if its parent is also a Couchbase\ndocument.\n* The `true` value is equivalent to `{}`.\n* The schema of the content of this custom property is available [here](src/main/resources/schema/document.json).\n\nThis property is responsible for generating the [`Document`](https://docs.spring.io/spring-data/couchbase/docs/current/api/org/springframework/data/couchbase/core/mapping/Document.html)\nannotation.\n\nE.g., this schema:\n```json\n{\n\t\"title\": \"Sample entity\",\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Document\npublic class Entity {\n\t...\n}\n```\n\nSome sub-properties are available to manage the annotation parameters (detailed in the annotation's documentation).\n\nE.g., this schema:\n```json\n{\n\t\"title\": \"Sample entity\",\n\t\"type\": \"object\",\n\t\"x-cb-document\": {\n\t\t\"expiry\": 2,\n\t\t\"expiryUnit\": \"MINUTES\",\n\t\t\"touchOnRead\": true\n\t},\n\t\"properties\": {\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Document(expiry = 2, expiryUnit = TimeUnit.MINUTES, touchOnRead = true)\npublic class Entity {\n\t...\n}\n```\n\n#### Composite indexes\n\nA sub-property `compositeIndexes` is available to declare indexes that will can be auto-generated by Spring\nData Couchbase via the [`CompositeQueryIndex`](https://docs.spring.io/spring-data/couchbase/docs/current/api/org/springframework/data/couchbase/core/index/CompositeQueryIndex.html)\nannotation and its parameters (detailed in the annotation's documentation).\n\nE.g., this schema:\n```json\n{\n\t\"title\": \"Sample entity\",\n\t\"type\": \"object\",\n\t\"x-cb-document\": {\n\t\t\"compositeIndexes\": [\n\t\t\t{\n\t\t\t\t\"fields\": [\n\t\t\t\t\t\"field1\",\n\t\t\t\t\t\"field12\"\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"fields\": [\n\t\t\t\t\t\"field2\",\n\t\t\t\t\t\"field3\",\n\t\t\t\t\t\"field4\"\n\t\t\t\t],\n\t\t\t\t\"name\": \"idx_fields\"\n\t\t\t}\n\t\t]\n\t},\n\t\"properties\": {\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Document(expiry = 2, expiryUnit = TimeUnit.MINUTES, touchOnRead = true)\n@CompositeQueryIndex(fields = {\n    \"field1\",\n    \"field2\"\n})\n@CompositeQueryIndex(fields = {\n    \"field3\",\n    \"field4\",\n    \"field5\"\n}, name = \"idx_fields\")\npublic class Entity {\n\t...\n}\n```\n\nYou can find more information on Spring Data Couchbase index creation and how to activate it here [here](https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#couchbase.repository.indexing).\n\n#### Exclude a POJO from Couchbase related elements\n\nIf `x-cb-document` is `false`, Couchbase related elements will be skipped for the generated class, also for its fields\nand its sub-objects.\n\n### Document id\n\nAt the property of an object level, it is possible to define a field as being a document id using the custom JSON\nproperty `x-cb-id`.\n\n* If missing, the value of this property is `false`.\n* The `true` value is equivalent to `{}`.\n* The schema of the content of this custom property is available [here](src/main/resources/schema/id.json).\n\nThis property is responsible for generating the [`Id`](https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/annotation/Id.html)\nannotation.\n\nE.g., this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"id\": {\n\t\t\t\"title\": \"Entity id\",\n\t\t\t\"type\": \"string\",\n\t\t\t\"x-cb-id\": true\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Id\nprivate String id;\n```\n\n#### Generated id\n\nA sub-property `generated` is available to manage the generating of the [`GeneratedValue`](https://docs.spring.io/spring-data/couchbase/docs/current/api/org/springframework/data/couchbase/core/mapping/id/GeneratedValue.html)\nannotation and its parameters (detailed in the annotation's documentation).\n\nE.g., this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"id\": {\n\t\t\t\"title\": \"Entity id\",\n\t\t\t\"type\": \"string\",\n\t\t\t\"format\": \"uuid\",\n\t\t\t\"x-cb-id\": {\n\t\t\t\t\"generated\": true\n\t\t\t}\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Id\n@GeneratedValue\nprivate UUID id;\n```\n\nAnd this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"id\": {\n\t\t\t\"title\": \"Entity id\",\n\t\t\t\"type\": \"string\",\n\t\t\t\"x-cb-id\": {\n\t\t\t\t\"generated\": {\n\t\t\t\t\t\"delimiter\": \"::\",\n\t\t\t\t\t\"strategy\": \"USE_ATTRIBUTES\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Id\n@GeneratedValue(delimiter = \"::\", strategy = GenerationStrategy.USE_ATTRIBUTES)\nprivate String id;\n```\n\nYou can find more information on Spring Data Couchbase key generation [here](https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#couchbase.autokeygeneration).\n\n### Document CAS\n\nAt the property of an object level, it is possible to define a field as being a document CAS (Compare And Swap) using\nthe custom JSON property `x-cb-cas`.\n\nIf missing, the value of this property is `false`.\n\nThis property is responsible for generating the [`Version`](https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/annotation/Version.html)\nannotation.\n\nNote that the type of a CAS field must be `Long` or `long`. This can be achieved through a `formatTypeMapping` or the\n`useLongIntegers` option.\n\nE.g., this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"cas\": {\n\t\t\t\"title\": \"Couchbase CAS\",\n\t\t\t\"type\": \"integer\",\n\t\t\t\"format\": \"int64\",\n\t\t\t\"x-cb-cas\": true\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Version\nprivate Long cas;\n```\n\n### Document field\n\nAt the property of an object level, it is possible to define a field as being a document id using the custom JSON\nproperty `x-cb-field`.\n\n* If missing and if the field is not already marked as being an id, a cas or a join, the value of this property is\n`true`.\n* If missing and if the field is already marked as being an id, a cas or a join, the value of this property is\n`false`.\n* The `true` value is equivalent to `{}`.\n* The schema of the content of this custom property is available [here](src/main/resources/schema/field.json).\n\nThis property is responsible for generating the [`Field`](https://docs.spring.io/spring-data/couchbase/docs/current/api/org/springframework/data/couchbase/core/mapping/Field.html)\nannotation.\n\nE.g., this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"field\": {\n\t\t\t\"title\": \"A field\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Field\nprivate String field;\n```\n\nSome sub-properties are available to manage the annotation parameters (detailed in the annotation's documentation).\n\nE.g., this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"field\": {\n\t\t\t\"title\": \"A field\",\n\t\t\t\"type\": \"string\",\n\t\t\t\"x-cb-field\": {\n\t\t\t\t\"name\": \"field_\",\n\t\t\t\t\"order\": 5\n\t\t\t}\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Field(name = \"field_\", order = 5)\nprivate String field;\n```\n\n#### Use field for id generation\n\nAn `idPrefix` sub-property is available to manage the the [`IdAttribute`](https://docs.spring.io/spring-data/couchbase/docs/current/api/org/springframework/data/couchbase/core/mapping/id/IdAttribute.html)\nannotation and its parameters (detailed in the annotation's documentation).\n\nE.g., this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"field\": {\n\t\t\t\"title\": \"A field\",\n\t\t\t\"type\": \"string\",\n\t\t\t\"x-cb-field\": {\n\t\t\t\t\"idAttribute\": true\n\t\t\t}\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Field\n@IdAttribute\nprivate String field;\n```\nAnd this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"field\": {\n\t\t\t\"title\": \"A field\",\n\t\t\t\"type\": \"string\",\n\t\t\t\"x-cb-field\": {\n\t\t\t\t\"idAttribute\": {\n\t\t\t\t\t\"order\": 2\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Field\n@IdAttribute(order = 2)\nprivate String field;\n```\n\nYou can find more information on Spring Data Couchbase key generation [here](https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#couchbase.autokeygeneration).\n\n#### Indexes\n\nA JSON sub-property `index` is available to declare indexes that will can be auto-generated by Spring\nData Couchbase via the [`QueryIndexed`](https://docs.spring.io/spring-data/couchbase/docs/current/api/org/springframework/data/couchbase/core/index/QueryIndexed.html)\nannotation and its parameters (detailed in the annotation's documentation).\n\nE.g., this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"field\": {\n\t\t\t\"title\": \"A field\",\n\t\t\t\"type\": \"string\",\n\t\t\t\"x-cb-field\": {\n\t\t\t\t\"index\": true\n\t\t\t}\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Field\n@QueryIndexed\nprivate String field;\n```\nAnd this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"field\": {\n\t\t\t\"title\": \"A field\",\n\t\t\t\"type\": \"string\",\n\t\t\t\"x-cb-field\": {\n\t\t\t\t\"index\": {\n\t\t\t\t\t\"direction\": \"ASCENDING\",\n\t\t\t\t\t\"name\": \"idx_sample\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Field\n@QueryIndexed(direction = QueryIndexDirection.ASCENDING, name = \"idx_sample\")\nprivate String field;\n```\n\nYou can find more information on Spring Data Couchbase index creation and how to activate it here [here](https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#couchbase.repository.indexing).\n\n### Non persisted fields for key generation\n\nAt property level, two JSON properties are available to use fields in code for key generation without persisting them,\nvia the following annotations and their parameters (detailed in the annotation's documentation).\n* `x-cb-idPrefix` for the [`IdPrefix`](https://docs.spring.io/spring-data/couchbase/docs/current/api/org/springframework/data/couchbase/core/mapping/id/IdPrefix.html)\nannotation.\n* `x-cb-id-suffix` for the [`IdSuffix`](https://docs.spring.io/spring-data/couchbase/docs/current/api/org/springframework/data/couchbase/core/mapping/id/IdSuffix.html)\nannotation.\n\nE.g., this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"prefix\": {\n\t\t\t\"title\": \"A field\",\n\t\t\t\"type\": \"string\",\n\t\t\t\"x-cb-idPrefix\": true\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@IdPrefix\nprivate String prefix;\n```\nAnd this schema:\n```json\n{\n\t\"...\"\n\t\"properties\": {\n\t\t\"...\"\n\t\t\"suffix\": {\n\t\t\t\"title\": \"A field\",\n\t\t\t\"type\": \"string\",\n\t\t\t\"x-cb-idSuffix\": {\n\t\t\t\t\"order\": 1\n\t\t\t}\n\t\t},\n\t\t\"...\"\n\t}\n}\n```\nWill produce:\n```java\n@Field\n@IdSuffix(order = 1)\nprivate String suffix;\n```\n\nYou can find more information on Spring Data Couchbase key generation [here](https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#couchbase.autokeygeneration).\n\n## Maven configuration\n\nHere is an example of how the extension can be added to the jsonschema2pojo Maven plugin.\n\n```xml\n\n\u003cplugin\u003e\n\t\u003cgroupId\u003eorg.jsonschema2pojo\u003c/groupId\u003e\n\t\u003cartifactId\u003ejsonschema2pojo-maven-plugin\u003c/artifactId\u003e\n\t\u003cversion\u003e${jsonschema2pojo.version}\u003c/version\u003e\n\t\u003cexecutions\u003e\n\t\t\u003cexecution\u003e\n\t\t\t\u003cgoals\u003e\n\t\t\t\t\u003cgoal\u003egenerate\u003c/goal\u003e\n\t\t\t\u003c/goals\u003e\n\t\t\t\u003cconfiguration\u003e\n\t\t\t\t...\n\t\t\t\t\u003c!-- Extension RuleFactory --\u003e\n\t\t\t\t\u003ccustomRuleFactory\u003e\n\t\t\t\t\tdev.hctbst.jsonschema2pojo.springframework.data.couchbase.SpringDataCouchbaseRuleFactory\n\t\t\t\t\u003c/customRuleFactory\u003e\n\t\t\t\u003c/configuration\u003e\n\t\t\u003c/execution\u003e\n\t\u003c/executions\u003e\n\t\u003cdependencies\u003e\n\t\t\u003c!-- Extension dependency --\u003e\n\t\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003edev.hctbst\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003ejsonschema2pojo-spring-data-couchbase\u003c/artifactId\u003e\n\t\t\t\u003cversion\u003e${jsonschema2pojo-spring-data-couchbase.version}\u003c/version\u003e\n\t\t\u003c/dependency\u003e\n\t\t\u003c!-- Spring Data Couchbase dependency --\u003e\n\t\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003espring-boot-starter-data-couchbase\u003c/artifactId\u003e\n\t\t\t\u003cversion\u003e${spring-boot.version}\u003c/version\u003e\n\t\t\u003c/dependency\u003e\n\t\u003c/dependencies\u003e\n\u003c/plugin\u003e\n```\n\nA more complete example is available [here](example).\n\n## License\n\nThis project is released under version 2.0 of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhectorbst%2Fjsonschema2pojo-spring-data-couchbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhectorbst%2Fjsonschema2pojo-spring-data-couchbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhectorbst%2Fjsonschema2pojo-spring-data-couchbase/lists"}