{"id":15673336,"url":"https://github.com/arey/hibernate-hydrate","last_synced_at":"2025-08-07T23:20:10.926Z","repository":{"id":2602842,"uuid":"3585756","full_name":"arey/hibernate-hydrate","owner":"arey","description":"Avoid Hibernate LazyInitializationException by recursively resolving proxy","archived":false,"fork":false,"pushed_at":"2025-07-12T10:59:05.000Z","size":348,"stargazers_count":18,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-17T11:36:51.765Z","etag":null,"topics":["hibernate"],"latest_commit_sha":null,"homepage":"http://javaetmoi.com/2012/03/hibernate-dites-adieu-aux-lazy-initialization-exception/","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/arey.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-02-29T20:47:42.000Z","updated_at":"2025-07-12T10:59:02.000Z","dependencies_parsed_at":"2025-04-19T10:33:18.518Z","dependency_job_id":"e8cb8e97-9ae0-40ed-a5ee-dd0b739c47f6","html_url":"https://github.com/arey/hibernate-hydrate","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/arey/hibernate-hydrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arey%2Fhibernate-hydrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arey%2Fhibernate-hydrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arey%2Fhibernate-hydrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arey%2Fhibernate-hydrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arey","download_url":"https://codeload.github.com/arey/hibernate-hydrate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arey%2Fhibernate-hydrate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269338600,"owners_count":24400317,"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-07T02:00:09.698Z","response_time":73,"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"],"created_at":"2024-10-03T15:39:48.868Z","updated_at":"2025-08-07T23:20:10.870Z","avatar_url":"https://github.com/arey.png","language":"Java","funding_links":[],"categories":["数据库开发"],"sub_categories":[],"readme":"# Hibernate Hydrate #\n\n[![Build Status](https://github.com/arey/hibernate-hydrate/actions/workflows/build.yml/badge.svg)](https://github.com/arey/hibernate-hydrate/actions/workflows/build.yml)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.javaetmoi.core/javaetmoi-hibernate6-hydrate/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.javaetmoi.core/javaetmoi-hibernate6-hydrate)\n\nThe primary goal of the [Hibernate Hydrate](https://github.com/arey/hibernate-hydrate) project is to populate a graph of persistent entities and thus avoid the famous [LazyInitializationException](http://docs.jboss.org/hibernate/orm/3.6/javadocs/org/hibernate/LazyInitializationException.html).\n\n## Features ##\n\n* Utility class to populate a lazy-initialized object graph by recursivity\n* Supports JPA with Hibernate as provider\n* Supports Hibernate 3.x to 6.x (with different artefactId)\n\n## Getting Help ##\n\nThis readme file as well as the [wiki](https://github.com/arey/hibernate-hydrate/wiki) are the best places to start learning about Hibernate Hydrate. \nThere are also unit tests available to look at.\n\nThe [wiki](https://github.com/arey/hibernate-hydrate/wiki) contains links to basic project information such as source code, jenkins build, javadocs, issue tracking, etc.\n\nA French article titled *Say goodbye to LazyInitializationException* : http://javaetmoi.com/2012/03/hibernate-dites-adieu-aux-lazy-initialization-exception/\n\n## Quick Start ##\n\n### Dependency ###\n\nDownload the jar though Maven:\n\n```xml\n\u003c!-- Either Hibernate 6.1.6 and above support --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.javaetmoi.core\u003c/groupId\u003e\n  \u003cartifactId\u003ejavaetmoi-hibernate6-hydrate\u003c/artifactId\u003e\n  \u003cversion\u003e6.3.4\u003c/version\u003e\n\u003c/dependency\u003e \n\n\u003c!-- or Hibernate 5.2 and above support --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.javaetmoi.core\u003c/groupId\u003e\n  \u003cartifactId\u003ejavaetmoi-hibernate5-hydrate\u003c/artifactId\u003e\n  \u003cversion\u003e5.2.4\u003c/version\u003e\n\u003c/dependency\u003e \n\n\u003c!-- or Hibernate 5.0 and 5.1 support --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.javaetmoi.core\u003c/groupId\u003e\n  \u003cartifactId\u003ejavaetmoi-hibernate5-hydrate\u003c/artifactId\u003e\n  \u003cversion\u003e2.3\u003c/version\u003e\n\u003c/dependency\u003e \n\n\u003c!-- or Hibernate 4 support --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.javaetmoi.core\u003c/groupId\u003e\n  \u003cartifactId\u003ejavaetmoi-hibernate4-hydrate\u003c/artifactId\u003e\n  \u003cversion\u003e2.2\u003c/version\u003e\n\u003c/dependency\u003e \n\n\u003c!-- or Hibernate 3 support --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.javaetmoi.core\u003c/groupId\u003e\n  \u003cartifactId\u003ejavaetmoi-hibernate3-hydrate\u003c/artifactId\u003e\n  \u003cversion\u003e2.2\u003c/version\u003e\n\u003c/dependency\u003e \n```\n\nPlease note that we are not able to support Hibernate versions 6.0 up to 6.1.5 due to bugs in them.\n\nHibernate Hydrate artefacts are available from [Maven Central](https://repo1.maven.org/maven2/com/javaetmoi/core/javaetmoi-hibernate6-hydrate/)\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.javaetmoi.core/javaetmoi-hibernate6-hydrate/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.javaetmoi.core/javaetmoi-hibernate6-hydrate)\n\n### Usage ###\n\nFirst get a `Hydrator` instance. There are four possible ways:\n* `Hydrator.hydrator(entityManagerFactory)`\n* `Hydrator.hydrator(entityManager)`\n* `Hydrator.hydrator(sessionFactory)`\n* `Hydrator.hydrator(session)`\n\nTo this `Hydrator` instance you can pass **attached** entities that need to be fully initialized.\nAfterward you can detach these entities and access all of their transitive attributes \nwithout getting problems with lazy loading. That is, there will be no `LazyInitializationException`.\n\nA simple example of a service method that returns a fully initialized entity \nexcept for its `mySubEntities` attribute:\n\n```java\nimport jakarta.persistence.EntityManager;\nimport jakarta.transaction.Transactional;\nimport com.javaetmoi.core.persistence.hibernate.Hydrator;\nimport static com.javaetmoi.core.persistence.hibernate.Hydrator.hydrator;\n\npublic class MyEntityService {\n  private final EntityManager entityManager;\n  private final Hydrator hydrator;\n\n  public MyEntityService(EntityManager entityManager) {\n    this.entityManager = entityManager;\n    this.hydrator = hydrator(entityManager).withExclude(MyEntity.class, \"mySubEntities\");\n  }\n\n  @Transactional\n  public MyEntity myEntity(long id) {\n    var myEntity = entityManager.find(MyEntity.class, id);\n    var myHydratedEntity = hydrator.deepHydrate(myEntity);\n    return myHydrateEntity;\n  }\n}\n```\n\n## Contributing to Hibernate Hydrate ##\n\n* GitHub is for social coding platform: if you want to write code, we encourage contributions through pull requests from [forks of this repository](http://help.github.com/forking/). \n  If you want to contribute code this way, please reference a GitHub ticket as well covering the specific issue you are addressing.\n* Each major version of Hibernate has it own git branch: \n  * Hibernate 6.2 on the master\n  * Hibernate 5 on the hibernate5 branch\n  * Hibernate 4 on the hibernate4 branch \n  * Hibernate 3 on the hibernate3 branch\n\n### Development environment installation ###\n\nDownload the code with git:\n\n``git clone git://github.com/arey/hibernate-hydrate.git``\n\nCompile the code with maven:\n\n``mvn clean install``\n\nIf you're using an IDE that supports Maven-based projects (IntelliJ Idea, Netbeans or m2Eclipse), you can import the project directly from its POM. \nOtherwise, generate IDE metadata with the related IDE maven plugin:\n\n``mvn eclipse:clean eclipse:eclipse``\n\n## Release\n\nThis project artefact is published to Maven Central.\nThe Maven Release Plugin is used to release the project with Maven.\nThe [release.yml](https://github.com/arey/hibernate-hydrate/actions/workflows/release.yml) GitHub Actions workflow automates the process.\n\n\n## Credits ##\n\n* Uses [Maven](http://maven.apache.org/) as a build tool\n* Uses [GitHub Actions](https://github.com/features/actions) for continuous integration builds whenever code is pushed into GitHub\n* [Izaak (John) Alpert](https://github.com/karlhungus) and [Marc Cobery](https://github.com/mcobery) and [Markus Heiden](https://github.com/markusheiden) for their pull requests\n \n\n## Build Status ##\n\nGitHub Actions: [![Java CI](https://github.com/arey/hibernate-hydrate/actions/workflows/build.yml/badge.svg)](https://github.com/arey/hibernate-hydrate/actions/workflows/build.yml)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farey%2Fhibernate-hydrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farey%2Fhibernate-hydrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farey%2Fhibernate-hydrate/lists"}