-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Projection Not working for Array Of Object [DATACMNS-1656] #2079
Comments
Mark Paluch commented If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem |
vr025 commented I think toMap() method needs to check boundary condition and if it is array or list set value.
private Object getProjectionTarget(Object source) { private Object getProjectionTarget(Object source) { if (source != null && source.getClass().isArray()) { source = Arrays.asList((Object[]) source); }
} |
Oliver Drotbohm commented It looks like we're not properly handling the returned array and invalidly try to create a single projecting instance of That said, your projection declaration is invalid: the query returns an array of You should be able to see this working by changing the type of That said, please make sure you properly format code in the examples you provide using the \{{code}} tags |
vr025 commented I have a PostgreSQL table which I mentioned in the description. That table has a colunmn with String Array type. When I try to access that column values through projection, the ResultProcessor.java file is throwing "index out of bound exception", I pasted the errors for your reference.
There is no Boundary conditions checked for list or set from a column.
|
Oliver Drotbohm commented Did you read my response to what you provided? Also, please refrain from messing with the ticket details. We use those for internal organization. Thanks |
vr025 commented After changing the repository method to List<String[]> I'm able to get the tags array for all the names in the organization table. Thanks Oliver for your inputs. However please let me know how to use projections for String Array.
Now I completely removed projection interface and changed my repository query like below to get all the list of tags for each name.
Modified Repository Query is here :
public List<String[]> findAllTags(); |
Projections are intended to retain their multiplicity. That being said, a |
vr025 opened DATACMNS-1656 and commented
We are using Projection to select just single Column that is String Array (String[]) and it is falling with Index out of bound exception.
Here is my table:
Here is my original entity mapping:
Here is Projection Interface:
Repository Query:
Error Logs :
Affects: 2.2.4 (Moore SR4)
Reference URL: https://github.com/spring-projects/spring-data-commons/blob/master/src/main/java/org/springframework/data/repository/query/ResultProcessor.java
The text was updated successfully, but these errors were encountered: