[
https://issues.apache.org/jira/browse/IGNITE-13028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17209206#comment-17209206
]
Denis A. Magda commented on IGNITE-13028:
-----------------------------------------
[~kazakov],
I believe the semantic needs to be as follows. If the one writes
*findById(<Type> s)*, then we'll be looking for the *id* field in a key or
value objects. If the one adds the *findByCountryCode(<Type> s)* method, then,
again, we'll be looking for the *countryCode* field in the same key or value
object. This corresponds to your option #2.
As for the collections vs. a single object as the return type, can't we support
both? My thinking was that the implementation can see what's an expected return
type. If the return type is a Collection, then we'll return all the objects
that might satisfy a condition, otherwise, we'll return a single object adding
the *LIMIT 1* clause in the generated SQL query.
> Spring Data integration doesn't introspect the fields of the key object
> -----------------------------------------------------------------------
>
> Key: IGNITE-13028
> URL: https://issues.apache.org/jira/browse/IGNITE-13028
> Project: Ignite
> Issue Type: Improvement
> Components: spring, springdata
> Affects Versions: 2.8
> Reporter: Denis A. Magda
> Assignee: Ilya Kazakov
> Priority: Major
> Labels: newbie
> Fix For: 2.10
>
>
> 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|https://github.com/GridGain-Demos/ignite-spring-data-demo/blob/master/src/main/java/org/gridgain/demo/springdata/dao/CityRepository.java#L42]:
> {code:java}
> @Query("SELECT * FROM City WHERE id = ?")
> public Cache.Entry<CityKey, City> findById(int id);
> {code}
> 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:
> {code:java}
> public Cache.Entry<CityKey, City> findById(int id);
> {code}
> 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
--
This message was sent by Atlassian Jira
(v8.3.4#803005)