admin管理员组文章数量:1327525
Up to the following version of hibernate-core
implementation '.hibernate.orm:hibernate-core:6.6.0.Alpha1'
it would be possible to perform the following code successfully:
INSERT INTO example_table (geom)
VALUES (
ST_SetSRID(
ST_GeomFromGeoJSON(
$dollar${"type":"Point","coordinates":[-34.4214,-15.9216]}$dollar$
),
4326
)
)
ON CONFLICT DO NOTHING;
Which hibernate would run the following statement:
INSERT INTO example_table (geom)
VALUES (
ST_SetSRID(
ST_GeomFromGeoJSON(
$dollar${"type":"Point","coordinates":[-34.4214,-15.9216]}$dollar$
),
4326
)
)
ON CONFLICT DO NOTHING;;
But after upgrading that dependency to:
implementation '.hibernate.orm:hibernate-core:6.6.0.CR1' OR ABOVE, the same query would cause hibernate to try to execute the following statement:
INSERT INTO example_table (geom)
VALUES (
ST_SetSRID(
ST_GeomFromGeoJSON(
$dollar$""""""{type:Point,coordinates:[-34.4214,-15.9216]}$dollar$
),
4326
)
)
ON CONFLICT DO NOTHING;;
Which leads to the following exception: [ERROR: unknown GeoJSON type] [n/a].
Those queries are run using EntityManager.createNativeQuery(query).
Does anyone know why this started happening (multiple double quotes in the query)? I couldn't find anything about it in the release notes. The only way I found to solve this issue was taking off the dollar quote and surrounding the json with single quotes, which is not what I want to do.
This happens to every version above 6.6.0.CR1, including the one used by spring data jpa from spring boot 3.4.x.
edit. 1
I need to use native queries for batch inserts with upsert behavior. Hibernate/JPA does not support operations like ON CONFLICT DO NOTHING.
edit. 2
This issue seems to happen with JSON data in general, not just with GeoJson type.
本文标签:
版权声明:本文标题:spring boot - Problem inserting json data using Hibernate entity manager after upgrading hibernate-core dependency version - Sta 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742196350a2431152.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论