Add json-columns module: JSON columns in Hibernate 7.4.14 (@JdbcTypeCode(SqlTypes.JSON)), JSONB querying, GIN/expression indexes, dirty checking, Jackson 3 vs 2 on PostgreSQL 18.6 and MySQL 8.0.46
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6Kg9RWSTJzyz6KP9X
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# PostgreSQL 18.6 on x86_64-pc-linux-gnu
|
||||
|
||||
== DDL
|
||||
id bigint
|
||||
name character varying
|
||||
address jsonb
|
||||
|
||||
== stored
|
||||
Asha {"zip": "411001", "city": "Pune", "floor": 3}
|
||||
Ravi {"zip": "400001", "city": "Mumbai", "floor": 12}
|
||||
Meera {"zip": "411045", "city": "Pune", "floor": 1}
|
||||
|
||||
== HQL: where c.address.city = 'Pune'
|
||||
sql> select c1_0.name from customer c1_0 where cast(c1_0.address->>'city' as varchar)='Pune' order by c1_0.id
|
||||
result: [Asha, Meera]
|
||||
|
||||
== HQL: select and order by an int attribute inside the JSON
|
||||
sql> select cast(c1_0.address->>'floor' as integer) from customer c1_0 where cast(c1_0.address->>'floor' as integer)>2 order by cast(c1_0.address->>'floor' as integer)
|
||||
result: [3, 12]
|
||||
|
||||
== HQL: update c.address.floor = 99
|
||||
sql> update customer c1_0 set address=coalesce(c1_0.address,'{}')||jsonb_build_object('floor',to_jsonb(99)) where c1_0.name='Ravi'
|
||||
rows updated: 1; stored: {"zip": "400001", "city": "Mumbai", "floor": 99}
|
||||
|
||||
== HQL: group by c.address.city
|
||||
sql> select cast(c1_0.address->>'city' as varchar),count(*) from customer c1_0 group by cast(c1_0.address->>'city' as varchar) order by cast(c1_0.address->>'city' as varchar)
|
||||
row: Mumbai 1
|
||||
row: Pune 2
|
||||
Reference in New Issue
Block a user