-
Notifications
You must be signed in to change notification settings - Fork 198
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
feat: dto with association #583
base: 4.7.x
Are you sure you want to change the base?
Conversation
Hello @graemerocher Could you please check this draft PR and let me know if you think this is the right direction to go. Sergio del Amo |
@@ -489,6 +508,18 @@ private boolean attemptProjection(@NonNull MethodMatchContext matchContext, @Non | |||
if (pp == null) { | |||
pp = entity.getIdOrVersionPropertyByName(propertyName); | |||
} | |||
SourcePersistentEntity association = null; | |||
if (pp == null && propertyName.endsWith(DtoJoinPathsParser.CAPITALIZED_ID)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems an arbitrary limitation this endsWith
check. I think entity.getPath(propertyName)
should be called since if that returns a path you have a query on any property of the association.
...processor/src/main/java/io/micronaut/data/processor/visitors/finders/DtoJoinPathsParser.java
Outdated
Show resolved
Hide resolved
Set<String> paths = new HashSet<>(); | ||
for (PropertyElement propertyElement : dto.getBeanProperties()) { | ||
final String name = propertyElement.getName(); | ||
if (name.endsWith(CAPITALIZED_ID)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also limiting the capability to just properties ending with Id
seems odd
@@ -101,7 +112,7 @@ public Object read(@NonNull S object, @NonNull Argument<?> argument) { | |||
* @param property THe property | |||
* @return The result | |||
*/ | |||
public @Nullable Object read(@NonNull S resultSet, @NonNull RuntimePersistentProperty<T> property) { | |||
public @Nullable Object read(@NonNull S resultSet, @NonNull RuntimePersistentProperty<?> property) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change necessary? If the association is being queried we probably should instantiate another DTOMapper
with the appropriate entity
No description provided.