{"id":16538031,"url":"https://github.com/acdcjunior/domain-id","last_synced_at":"2025-09-07T18:34:46.939Z","repository":{"id":57732221,"uuid":"184523850","full_name":"acdcjunior/domain-id","owner":"acdcjunior","description":"Domain Id Hibernate UserType implementation with Jackson serializers","archived":false,"fork":false,"pushed_at":"2024-05-17T22:00:02.000Z","size":348,"stargazers_count":0,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-14T05:11:31.182Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acdcjunior.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-02T05:04:27.000Z","updated_at":"2024-05-17T22:00:06.000Z","dependencies_parsed_at":"2022-08-28T03:21:38.207Z","dependency_job_id":null,"html_url":"https://github.com/acdcjunior/domain-id","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acdcjunior%2Fdomain-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acdcjunior%2Fdomain-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acdcjunior%2Fdomain-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acdcjunior%2Fdomain-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acdcjunior","download_url":"https://codeload.github.com/acdcjunior/domain-id/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241739543,"owners_count":20012105,"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":[],"created_at":"2024-10-11T18:44:16.385Z","updated_at":"2025-03-03T21:15:07.298Z","avatar_url":"https://github.com/acdcjunior.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# domain-id\n\nAn implementation for Domain IDs, as suggested by Implementing Domain Driven Design.\n\nThis library includes:\n\n- a `DomainId` base class;\n- a hibernate `UserType`, which allows you to map the IDs directly into entities;\n- a Jackson serializer and deserializer.\n\nImporting:\n\n```groovy\ndependencies {\n    implementation('io.github.acdcjunior:domain-id-all:0.2.0')\n```\n```xml\n\u003cdependencies\u003e\n\t\u003cdependency\u003e\n\t\t\u003cgroupId\u003eio.github.acdcjunior\u003c/groupId\u003e\n\t\t\u003cartifactId\u003edomain-id-all\u003c/artifactId\u003e\n\t\t\u003cversion\u003e0.2.0\u003c/version\u003e\n\t\u003c/dependency\u003e\n```\n\n**NOTE:** Although `domain-id-hibernate-usertype`'s code depends on hibernate and JPA, its `.jar` does not bring any dependencies.\nThat is **intentional**. Our purpose is not to force any specific Hibernate or Jackson (in the case of `domain-id-serializer-converter`)\nminor versions.\nYou should, therefore, declare the dependencies as usual (in your `build.gradle` or `pom.xml`) and guarantee\neverything works via at least one runtime test.\n\n\u003cbr\u003e\n\n\n# Declaring\n\nIn order to use an ID, you must declare some classes first. Basically, you'll declare the ID and that's all.\n\nThe hibernate `UserType` is automatically registered.\nThe Jackson serializer/deserializer may be registered, if you'll need it.\n\n### The ID class:\n\n```java\n// src/main/java/com/myservice/domain/myentity/MyEntityId.java\npackage com.myservice.domain.myentity;\n\nimport io.github.acdcjunior.domainid.DomainId;\n\npublic class MyEntityId extends DomainId {\n    public MyEntityId(long id) {\n        super(id);\n    }\n}\n```\n    \nAn hibernate `UserType` will be automatically registered for that ID class.\n    \n#### Add, if desired, the Jackson serializer/deserializer\n\n```java\n// src/main/java/com/myservice/MyServiceApplication.java\npackage com.myservice;\n\n// ...   \nimport io.github.acdcjunior.domainid.DomainIdSerializer;\n\n@SpringBootApplication(scanBasePackages = \"com.myservice\", scanBasePackageClasses = DomainIdSerializer.class)\npublic class MyServiceApplication {\n```\n\n\u003cbr\u003e\u003cbr\u003e\n    \n# Usage\n\nAfter the declarations above, use as follows:\n\n# Non-ID field:\n\n```java\n@Entity\n@Table(name = \"MY_ENTITY\", schema = \"MYSERVICE\")\npublic class MyEntity {\n\n    // ...\n\n    @Column\n    private OtherEntityId otherEntity;\n```\n\n#### Using as `@Id` and auto-generated using a Sequence:\n\n```java\nimport io.github.acdcjunior.domainid.hibernate.sequence.DomainIdSequenceStyleGenerator;\nimport org.hibernate.annotations.GenericGenerator;\n\nimport javax.persistence.*;\n\n@Entity\n@Table(name = \"MY_ENTITY\", schema = \"MYSERVICE\")\npublic class MyEntity {\n\n    @Id\n    @GenericGenerator(\n            name = \"SEQ_MY_ENTITY\",\n            strategy = DomainIdSequenceStyleGenerator.SEQUENCE,\n            parameters = @org.hibernate.annotations.Parameter(name = \"sequence_name\", value = \"MYSERVICE.SEQ_MY_ENTITY\")\n    )\n    @GeneratedValue(generator = \"SEQ_MY_ENTITY\", strategy = GenerationType.SEQUENCE)\n    @Column\n    private MyEntityId id;\n```\n\n\u003cbr\u003e\n\n# Details\n\n`@GenericGenerator` - Parameters:\n\n- `sequence_name`: Sequence's full name, including the schema/owner name. Example: `MY_SCHEMA.MY_ENTITY_SEQ`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facdcjunior%2Fdomain-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facdcjunior%2Fdomain-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facdcjunior%2Fdomain-id/lists"}