-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
-
None
After we finished BsonArray embedding, a natural next step is to implement some basic array SQL function to use in WHERE clause, including (see https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#hql-functions-arrays):
- array_contains
- array_includes
So for the following HQL:
select * from Book where array_contains(tags, "classic")
for the following Book entity:
@Entity @Table(name = "books") class Book { @Id int id; String title; List<String> tags; }
The difference between the two functions is the former test a single value (like the example above), whereas the latter tests on another array to see whether it is a subset.
There are many array SQL functions but the above two are the most basic ones and should satisfy lots of requirements.
Hibernate extension points:
- initializeFunctionRegistry method in Dialect (we could register custom SQL function in Dialect, just as we can register custom types as we have done for ObjectId type; see relevant Hibernate user guide: https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#hql-user-defined-functions)
PoC PR:
- commit: https://github.com/NathanQingyangXu/jpa-mongodb-mapping/commit/964d00a33c24430d032c6f6978287948735bfbd0 and https://github.com/NathanQingyangXu/jpa-mongodb-mapping/commit/d12f1f41199194aa8283fcf984a4c4f9263af0b2
- Test case:
org.hibernate.omm.type.aray.SimpleArrayFieldTests#test_query_mongo_embedded_array_field()
- depends on
-
HIBERNATE-62 Simple select query statement implementation
-
- In Code Review
-
-
HIBERNATE-58 Embedding simple BsonArray
-
- Ready for Work
-
- related to
-
HIBERNATE-77 implement $in and $nin comparison operator
-
- Backlog
-