- 
    Type:Task 
- 
    Resolution: Done
- 
    Priority:Unknown 
- 
    None
- 
        3
- 
        🔵 Done
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
Estimate: 2 weeks.
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-58 Support arrays/collections mapping -         
- Closed
 
-         
- 
                    HIBERNATE-62 Simple select query statement implementation -         
- Closed
 
-         
- related to
- 
                    HIBERNATE-77 Support HQL in / not in -         
- Backlog
 
-         
- links to