{"id":15013860,"url":"https://github.com/honoluluhenk/id-class","last_synced_at":"2026-02-17T16:34:30.286Z","repository":{"id":57720068,"uuid":"345780036","full_name":"HonoluluHenk/id-class","owner":"HonoluluHenk","description":"Typesafe value-object for use in persistence and/or (Jax-)DTOs","archived":false,"fork":false,"pushed_at":"2022-08-19T23:08:48.000Z","size":140,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-21T04:26:32.779Z","etag":null,"topics":["hibernate","jackson","java","jpa","quarkus","spring"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HonoluluHenk.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":"2021-03-08T20:04:05.000Z","updated_at":"2022-08-19T23:09:17.000Z","dependencies_parsed_at":"2022-09-26T21:41:08.215Z","dependency_job_id":null,"html_url":"https://github.com/HonoluluHenk/id-class","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/HonoluluHenk/id-class","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HonoluluHenk%2Fid-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HonoluluHenk%2Fid-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HonoluluHenk%2Fid-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HonoluluHenk%2Fid-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HonoluluHenk","download_url":"https://codeload.github.com/HonoluluHenk/id-class/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HonoluluHenk%2Fid-class/sbom","scorecard":{"id":63137,"data":{"date":"2025-08-11","repo":{"name":"github.com/HonoluluHenk/id-class","commit":"c144ad74eb93cd7f505a7b7898f52391e394f947"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU Lesser General Public License v3.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-15T02:07:12.374Z","repository_id":57720068,"created_at":"2025-08-15T02:07:12.374Z","updated_at":"2025-08-15T02:07:12.374Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273047319,"owners_count":25036334,"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","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["hibernate","jackson","java","jpa","quarkus","spring"],"created_at":"2024-09-24T19:44:51.974Z","updated_at":"2026-02-17T16:34:25.253Z","avatar_url":"https://github.com/HonoluluHenk.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## id-class\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.honoluluhenk.id-class/id-class)](https://search.maven.org/artifact/com.github.honoluluhenk.id-class/id-class)\n[![Issues](https://img.shields.io/github/issues/HonoluluHenk/id-class)](https://github.com/HonoluluHenk/id-class/issues)\n[![GitHub contributors](https://img.shields.io/github/contributors/HonoluluHenk/id-class)](https://github.com/HonoluluHenk/id-class/graphs/contributors)\n[![GitHub stars](https://img.shields.io/github/stars/HonoluluHenk/id-class?style=social)](https://github.com/HonoluluHenk/id-class)\n[![GitHub forks](https://img.shields.io/github/forks/HonoluluHenk/id-class?style=social)](https://github.com/HonoluluHenk/id-class/network/members)\n\nHelps binding IDs of objects/entities to their type and thus prevents using IDs for the wrong object/entity - and\nimplicitly documents the entity-type associated to the ID.\n\n## Motivation\n\nHave you ever mixed up your variables containing UUID/String/Long/... IDs in JPA/Hibernate/JAX-RS or other frameworks?\n\nLike maybe so?\n\n```java\nimport java.util.UUID;\n\nclass SomeEntity {\n\t@Id\n\tpublic UUID id = UUID.randomUUID();\n}\n\nclass OtherEntity {\n\t@Id\n\tpublic UUID id;\n}\n\nclass Foo {\n\tvoid doStuff(OtherEntity otherEntity) {\n\t\t// id gets \"transformed\" to id of wrong entity:\n\t\tUUID id = otherEntity.getId();\n\n\t\t// and now you e.g. try to load SomeEntity\n\t\t// with the id of OtherEntity but did not find anything:\n\t\tSomeEntity someEntity = entityManager.find(SomeEntity.class, id);\n\t}\n}\n```\n\n*id-class* to the rescue: now you can have typed IDs bound to the entity-type:\n\n```java\nimport com.github.honoluluhenk.idclass.ID;\n\npublic class SomeEntity {\n\t@Id\n\tpublic ID\u003cSomeEntity\u003e id = ID.randomUUID(SomeEntity.class); // directly support ID generation\n}\n\nclass OtherEntity {\n\t@Id\n\tpublic UUID id;\n}\n\nclass Foo {\n\tvoid doStuff(OtherEntity otherEntity) {\n\t\t// compiler error: ID\u003cOtherEntity\u003e is not compatible with ID\u003cSomeEntity\u003e\n\t\tID\u003cSomeEntity\u003e id = otherEntity.getId();\n\n\t\t// direct integration into hibernate!\n\t\tSomeEntity someEntity = entityManager.find(SomeEntity.class, id);\n\t}\n}\n\n```\n\n(this example is using UUIDs, but there are more options and it's customizable)\n\nYou will also find modules to integrate this nicely into\n\n* [JAX-RS with Jackson](https://github.com/FasterXML/jackson)\n* [JPA with Hibernate](https://hibernate.org/)\n\n## Installation/Basic Usage\n\n### Just the basic ID class\n\nInstall using maven:\n\n```xml\n\n\u003cdependencies\u003e\n\t\u003cdependency\u003e\n\t\t\u003cgroupId\u003ecom.github.honoluluhenk.id-class\u003c/groupId\u003e\n\t\t\u003cartifactId\u003eid-class\u003c/artifactId\u003e\n\t\t\u003cversion\u003e${id-class-parent.version}\u003c!-- see github releases --\u003e\u003c/version\u003e\n\t\u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\nBasic usage:\n\nThe ID class mainly consists of various factory methods:\n\n```java\nclass Foo {\n\tprivate ID\u003cFoo\u003e id = ID.randomUUID();\n\tprivate ID\u003cFoo\u003e id = ID.of(UUID.fromString(\"af897f93-9067-48a3-96aa-974511a5c3c4\"));\n\tprivate ID\u003cFoo\u003e id = ID.of(\"cb310f0f-596e-48f5-b6b6-25301d589fe5\");\n\t//... and more\n}\n```\n\nID is immutable, comes with hashCode()/equals(), a nice toString() and implements Serializable.\n\nSee javadoc comments or [ID.java source](id-class/src/main/java/com/github/honoluluhenk/idclass/ID.java).\n\nMost of its value actually comes from using it in one of the integrations, see below.\n\n### Jackson Integration\n\nInstall using maven (also pulls in the basic ID class):\n\n```xml\n\n\u003cdependencies\u003e\n\t\u003cdependency\u003e\n\t\t\u003cgroupId\u003ecom.github.honoluluhenk.id-class\u003c/groupId\u003e\n\t\t\u003cartifactId\u003eid-class-jackson-integration\u003c/artifactId\u003e\n\t\t\u003cversion\u003e${id-class-parent.version}\u003c/version\u003e\n\t\u003c/dependency\u003e\n\t\u003c!-- optional, depending on your requirements: --\u003e\n\u003c/dependencies\u003e\n```\n\n**You need to declare dependencies to jackson yourself (so you don't end up in dependency hell)!**\n\nJackson integration contains two parts:\n\n* a [ParamConverter](https://docs.oracle.com/javaee/7/api/javax/ws/rs/ext/ParamConverter.html)\n  / [ParamConverterProvider](https://docs.oracle.com/javaee/7/api/javax/ws/rs/ext/ParamConverterProvider.html) to make\n  REST @PathParams work (automatically configured by\n  the [`@Provider`](https://docs.oracle.com/javaee/7/api/javax/ws/rs/ext/Provider.html) annotation)\n* a Jackson module containing Serializer/Deserializer to convert IDs in object bodys.\n\n**You need to manually customize the Jackson\nDatabind [`ObjectMapper`](https://fasterxml.github.io/jackson-databind/javadoc/2.7/com/fasterxml/jackson/databind/ObjectMapper.html)\n.**\n\nFortunately, There's a module for that:\n\n```java\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport com.github.honoluluhenk.idclass.integration.jackson.IDTypeModule;\n\nclass MyObjectMapperCustomizer {\n\tvoid customize(ObjectMapper om) {\n\t\tom.registerModule(new IDTypeModule());\n\t}\n}\n```\n\nNow you can use it in all possible places in JAX-RS ressources/DTOs:\n\n```java\nclass JaxHello {\n\tprivate ID\u003cSomeEntity\u003e entityID;\n\tprivate String name;\n    private Map\u003cID\u003cSomeEntity\u003e, SomeEntity\u003e entityMap;\n\t// getters/setters omitted for brevity\n}\n\n@Path(\"hello\")\npublic class HelloResource {\n\n\t@POST\n\t@Path(\"{id}\")\n\tpublic JaxHello sayHello(@PathParam(\"id\") ID\u003cSomeEntity\u003e entityID) {\n\t\treturn someService.findEntity(entityID);\n\t}\n} \n```\n\n### JPA/Hibernate Integration\n\nInstall using maven (also pulls in the basic ID class):\n\n```xml\n\n\u003cdependencies\u003e\n\t\u003cdependency\u003e\n\t\t\u003cgroupId\u003ecom.github.honoluluhenk.id-class\u003c/groupId\u003e\n\t\t\u003cartifactId\u003eid-class-jpa-hibernate-integration\u003c/artifactId\u003e\n\t\t\u003cversion\u003e${id-class-parent.version}\u003c/version\u003e\n\t\u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n**You need to declare dependencies to hibernate yourself (so you don't end up in dependency hell)!**\n\nNo you can start using the converter by attaching the\nHibernate [`@Type` or `@TypeDef` annotation](https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#basic-custom-type)\nto the field in your entity:\n\n```java\nimport com.github.honoluluhenk.idclass.ID;\nimport org.hibernate.annotations.Type;\n\n@Entity\npublic class SomeEntity {\n\t@Id\n\t@Type(type = \"com.github.honoluluhenk.idclass.integration.jpahibernate.IDType\")\n\tprivate ID\u003cSomeEntity\u003e id;\n\n\t// ...\n}\n```\n\n### JPA EntityManager enhancements\n\nInstall using maven (also pulls in id-class-jpa-hibernate-integration and the basic id-class).\n\n```xml\n\n\u003cdependencies\u003e\n\t\u003cdependency\u003e\n\t\t\u003cgroupId\u003ecom.github.honoluluhenk.id-class\u003c/groupId\u003e\n\t\t\u003cartifactId\u003eid-class-jpa22-smartentitymanager\u003c/artifactId\u003e\n\t\t\u003c!-- JPA 2.1: (please open an issue if you need another JPA 2.x version)\n\t\t\u003cartifactId\u003eid-class-jpa21-smartentitymanager\u003c/artifactId\u003e\n\t\t--\u003e\n\t\t\u003cversion\u003e${id-class-parent.version}\u003c/version\u003e\n\t\u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\nThis package enhances the standard JPA EntityManager so you can use the ID classes directly.\n\nThis also works with [Spring-Data](https://spring.io/projects/spring-data-jpa)!\n\n```java\nimport com.github.honoluluhenk.idclass.ID;\nimport com.github.honoluluhenk.idclass.integration.jpahibernate.SmartEntityManager;\n\n@RequestScoped\n@Transactional\nclass MyDAO {\n\n\t@PersistenceContext\n\tprivate EntityManager em;\n\n\tprivate SmartEntityManager db() {\n\t\treturn new SmartEntityManager(em);\n\t}\n\n\t// easier in the long run: implement your own @Producer and directly inject here:\n\t// @Inject\n\t// private SmartEntityManager sem;\n\n\tpublic MyEntity findById(ID\u003cMyEntity\u003e entityID) {\n\t\treturn db()\n\t\t\t\t.find(entityID);\n\t}\n\n\t// also implemented: Java8 Optionals:\n\tpublic Optional\u003cMyEntity\u003e findOneByID(ID\u003cMyEntity\u003e entityID) {\n\t\treturn db()\n\t\t\t\t.findOne(entityID);\n\t\t\n\t\t// same for Query/TypedQuery/StoreProcedureQuery: query.getSoleResult()\n\t}\n}\n\n```\n\nSmartEntityManager might also be injected via e.g. your own @Produce method (CDI) or a Spring FactoryBean.\n\nExample for a CDI producer:\n\n```java\nimport javax.enterprise.inject.Produces;\n\nimport com.github.honoluluhenk.idclass.integration.jpahibernate.SmartEntityManager;\n\n@ApplicationScoped\npublic class SmartEntityManagerProducer {\n\t@PersistenceContext\n\tEntityManager defaultEntitymanager;\n\n\t@Produces\n\t@RequestScoped\n\tpublic SmartEntityManager produceSmartEntityManager() {\n\t\treturn new SmartEntityManager(defaultEntitymanager);\n\t}\n}\n```\n\n## Credits\n\nThanks to [Fabio](https://github.com/xfh) for this great idea a long time ago!\n\n## License\n\n[GNU Lesser General Public License V3 (LGPLv3)](https://www.gnu.org/licenses/lgpl-3.0.html), see [LICENSE](LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhonoluluhenk%2Fid-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhonoluluhenk%2Fid-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhonoluluhenk%2Fid-class/lists"}