-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[3.2.1] Indexing Class with Custom Converter -> Couldn't find PersistentEntity for property private [...] #3659
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
Comments
Can you please add the structure of all involved classes ( |
@christophstrobl Thanks for your feedback. While trying to distill a minimal example, I figured out that the issue arises when the following mongo converter is enabled: @WritingConverter
public static class IntervalToDocumentConverter implements Converter<Interval, Document> {
@Override
public Document convert(Interval interval) {
var doc = new Document();
doc.put("start", Date.from(interval.getStart()));
doc.put("end", Date.from(interval.getEnd()));
return doc;
}
} The converter gets registered via The Entity: @Document
public class Customer {
@Id
private ObjectId id;
private String name;
private Interval validInterval;
} Index creation public void initIndicesAfterStartup() {
var indexOps = mongoOperations.indexOps(Customer.class);
try {
indexOps.dropIndex("TextIndex");
}catch (Exception e){}
indexOps.ensureIndex(
TextIndexDefinition
.builder()
.named("TextIndex")
.onField("name")
.onField("validInterval.start")
.build()
);
} With the converter registered, it leads to the following error:
If I disable the converter it works. |
Here is an minimal example project. Simply start the App Server and you will see the exception. https://gitlab.com/elderbyte/public/examples/spring-mongo-index-issue |
@christophstrobl I have now created an reproducible example project & also updated the issue description to reflect the latest discoveries. |
thanks @IsNull - we'll have a look. Might take some time though. |
@christophstrobl Further investigation shows that the problem is not only with custom converters defined by users, but even with standard converters provided by spring. For example, indexing the spring @Document
public class Customer {
@Id
private ObjectId id;
private String name;
private org.springframework.data.geo.Box box;
}
I consider this a major bug / regression which should be fixed with high priority. Same Stacktrace:
|
Types having a write |
spring-projects/spring-data-commons#2293 changed how PersistentProperty paths get resolved and considers potentially registered converters for those, which made the path resolution fail in during the query mapping process. This commit makes sure to capture the according exception and continue with the given user input. Fixes: #3659
We are also hitting this when trying to execute
This blocks upgrades to Spring Boot 2.5.X. Hope the fix gets merged soon. |
@IsNull Thanks for reporting this! |
spring-projects/spring-data-commons#2293 changed how PersistentProperty paths get resolved and considers potentially registered converters for those, which made the path resolution fail in during the query mapping process. This commit makes sure to capture the according exception and continue with the given user input. Fixes: #3659 Original pull request: #3661.
spring-projects/spring-data-commons#2293 changed how PersistentProperty paths get resolved and considers potentially registered converters for those, which made the path resolution fail in during the query mapping process. This commit makes sure to capture the according exception and continue with the given user input. Fixes: #3659 Original pull request: #3661.
We updated from spring boot 2.4.2 to 2.5.0, and now Index creation is broken. This means the same code that worked before wont under 2.5.0. (spring-data-mongodb
3.1.3
to3.2.1
)I have created a sample Project which shows the problem: https://gitlab.com/elderbyte/public/examples/spring-mongo-index-issue
Creating an mongo index fails, when the dot path notation is used and the referenced class
is in a separate libraryhas a custom mongo converter:The entity for which this index is being defined looks like this (simplified):
Creating an Index via ensure index yields an unexpected exception:
Stacktrace
Conclusions:
3.2.1
of spring-data-mongodb2.4.2
where the same code works (3.1.3
of spring-data-mongodb)2.4.6
also works (3.1.9 spring-data-mongodb)The classcom.elderbyte.commons.i18n.I18nText
is in another library which is a gradle (maven) dependency.Repository Base package has been set tocom.elderbyte
so it should include both classesIf I copy the class from that library into the local project, it works.Any idea what could have caused this and how to fix it?
The text was updated successfully, but these errors were encountered: