Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.8
-
Spring Data integration introspects the fields of the key object (in case of using compound key)
-
Docs Required, Release Notes Required
Description
Suppose you have key and value POJOs associated with Ignite caches/tables:
- Key: https://github.com/GridGain-Demos/ignite-spring-data-demo/blob/master/src/main/java/org/gridgain/demo/springdata/model/CityKey.java
- Value: https://github.com/GridGain-Demos/ignite-spring-data-demo/blob/master/src/main/java/org/gridgain/demo/springdata/model/City.java
The key object includes a couple of fields (id and countryCode) that are not visible to the Spring's query-autogeneration feature. For instance, you have to use direct queries if want to get all the cities with a specific value of id field:
@Query("SELECT * FROM City WHERE id = ?") public Cache.Entry<CityKey, City> findById(int id);
If the query-autogeneration feature could introspect the metadata of the key, then you would not need to fall back to the direct queries and would add the following query to the repository:
public Cache.Entry<CityKey, City> findById(int id);
The same issue exists if a key is of a primitive type (Integer, String, etc.)
To reproduce you can use this project:
https://github.com/GridGain-Demos/ignite-spring-data-demo
Attachments
Issue Links
- links to