{"id":16619987,"url":"https://github.com/cepr0/pg-uuid-projection-exception","last_synced_at":"2025-07-19T22:37:26.456Z","repository":{"id":130472392,"uuid":"131062728","full_name":"Cepr0/pg-uuid-projection-exception","owner":"Cepr0","description":"Native query method with UUID and projection on PostgreSQL throws an exception","archived":false,"fork":false,"pushed_at":"2018-04-26T10:12:46.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T22:09:21.970Z","etag":null,"topics":["native-query","postgresql","projection","spring-boot","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-04-25T20:56:12.000Z","updated_at":"2020-08-27T15:15:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"9b150a35-a094-46b8-9836-4132be68049f","html_url":"https://github.com/Cepr0/pg-uuid-projection-exception","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fpg-uuid-projection-exception","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fpg-uuid-projection-exception/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fpg-uuid-projection-exception/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fpg-uuid-projection-exception/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cepr0","download_url":"https://codeload.github.com/Cepr0/pg-uuid-projection-exception/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242988204,"owners_count":20217563,"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":["native-query","postgresql","projection","spring-boot","spring-data-jpa"],"created_at":"2024-10-12T02:43:14.361Z","updated_at":"2025-03-11T07:19:02.825Z","avatar_url":"https://github.com/Cepr0.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Native query method with **projection** containing **UUID** properties throws an exception:\n\n\u003e org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111 \n\n(tested on **PostgreSQL**)\n\nExample:\n\n```java\n@Entity\npublic class Model {\n\n\t@Id\n\t@GeneratedValue(strategy = GenerationType.AUTO)\n\tprivate UUID id;\n\tprivate UUID uuid;\n}\n\n@Query(value = \"select m.id as id, m.uuid as uuid from model m where m.id = ?1\", nativeQuery = true)\nOptional\u003cModelProjection\u003e getModelProjection(UUID id);\n```\n\nNative query with entity class works as expected.\n\nHow to reproduce:\n\n1. Create database `uuid-demo` in PostgreSQL server (with username and password `postgres` - see 'application.properties')\n2. Run test `io.github.cepr0.demo.ModelRepoTest`\n\nTo workaround this I created a custom PostgreSQL dialect class:\n\n```java\npublic class CustomPostgreSQL95Dialect extends PostgreSQL95Dialect {\n\t\n\tpublic PatchedPostgreSQL95Dialect() {\n\t\tsuper();\n\t\tregisterHibernateType(Types.OTHER, \"org.hibernate.type.PostgresUUIDType\");\n\t}\n}\n``` \n\nAnd set it in the 'application.properties'\n\n`spring.jpa.properties.hibernate.dialect=io.github.cepr0.demo.CustomPostgreSQL95Dialect`\n\nP.S. During testing, it turned out that [class-based projections](https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#projections.dtos) \ndoes not work with native queries - they throw an exception:\n\n```\norg.springframework.core.convert.ConverterNotFoundException: \nNo converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] \nto type [io.github.cepr0.demo.ModelDto]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcepr0%2Fpg-uuid-projection-exception","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcepr0%2Fpg-uuid-projection-exception","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcepr0%2Fpg-uuid-projection-exception/lists"}