{"id":16620003,"url":"https://github.com/cepr0/hibernate-types-in-projection","last_synced_at":"2026-04-14T23:33:14.899Z","repository":{"id":130472290,"uuid":"161234247","full_name":"Cepr0/hibernate-types-in-projection","owner":"Cepr0","description":"Bad attempt to use json or array types of hibernate-types lib in Spring Data projections","archived":false,"fork":false,"pushed_at":"2018-12-10T21:03:09.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-26T15:34:56.660Z","etag":null,"topics":["array","hibernate-types","json","postgresql","projection","spring-data-jpa"],"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/Cepr0.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-10T20:45:03.000Z","updated_at":"2021-10-08T04:57:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"1cf86f9d-f5c4-4c8b-b244-a14e076c1374","html_url":"https://github.com/Cepr0/hibernate-types-in-projection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Cepr0/hibernate-types-in-projection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fhibernate-types-in-projection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fhibernate-types-in-projection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fhibernate-types-in-projection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fhibernate-types-in-projection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cepr0","download_url":"https://codeload.github.com/Cepr0/hibernate-types-in-projection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fhibernate-types-in-projection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277261217,"owners_count":25788578,"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-09-27T02:00:08.978Z","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":["array","hibernate-types","json","postgresql","projection","spring-data-jpa"],"created_at":"2024-10-12T02:43:16.723Z","updated_at":"2025-10-05T03:07:12.057Z","avatar_url":"https://github.com/Cepr0.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"An attempt to use json/array types of [hibernate-types](https://github.com/vladmihalcea/hibernate-types) in Spring Data projections\n\nProjection:\n\n```java\npublic interface ParentProjection {\n\tString getName();\n\tList\u003cString\u003e getChildNames();\n}\n```\n\nQuery:\n\n```java\n@Query(value = \"\" +\n        \"select \" +\n        \"  p.name as name, \" +\n        \"  array_agg(c.name) as childNames \" +\n        \"from \" +\n        \"  parents p \" +\n        \"  join children c on c.parent_id = p.id \" +\n        \"where \" +\n        \"  p.id = ?1 \" +\n        \"group by \" +\n        \"  p.name\" +\n        \"\", nativeQuery = true)\nOptional\u003cParentProjection\u003e getParentWithChildNamesAsArray(Integer id);\n```\n\n[Custom Postgres dialect](https://vladmihalcea.com/hibernate-no-dialect-mapping-for-jdbc-type/):\n\n```java\npublic class PostgreSQLCustomDialect extends PostgreSQL95Dialect {\n\n\tpublic PostgreSQLCustomDialect() {\n\t\tsuper();\n\t\tregisterHibernateType(Types.OTHER, JsonNodeStringType.class.getName());\n\t\tregisterHibernateType(Types.ARRAY, StringArrayType.class.getName());\n\t}\n}\n```\n\nWhen PostgreSQL aggregate function `array_agg` is used in the query above, \nthen the following exception is raised:\n\n    org.springframework.orm.jpa.JpaSystemException: Could not instantiate Type: com.vladmihalcea.hibernate.type.array.StringArrayType;\n    \nIf `json_agg` function is used, then we have another exception:\n\n    java.lang.IllegalArgumentException: Projection type must be an interface!  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcepr0%2Fhibernate-types-in-projection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcepr0%2Fhibernate-types-in-projection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcepr0%2Fhibernate-types-in-projection/lists"}