Skip to content

Commit 6f65e43

Browse files
committed
Merge branch 'copilot/migrate-mongo-repository-to-nitrite' of github.com:dizitart/nitrite-database into copilot/migrate-mongo-repository-to-nitrite
2 parents 3c22c53 + a3a028f commit 6f65e43

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

nitrite/src/main/java/org/dizitart/no2/repository/Reflector.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ private <T> Field getFieldFromInterfaceProperty(Class<T> interfaceType, String p
193193

194194
if (propertyName.equals(extractedPropertyName)) {
195195
// Found matching getter - create a wrapper field
196-
// For now, we return null and will handle this case specially
197-
// Actually, let's throw a more helpful error with a workaround suggestion
198196
return createSyntheticFieldForProperty(propertyName, method);
199197
}
200198
}
@@ -209,8 +207,12 @@ private <T> Field getFieldFromInterfaceProperty(Class<T> interfaceType, String p
209207
*/
210208
private Field createSyntheticFieldForProperty(String propertyName, Method getterMethod) {
211209
try {
212-
// Use a generic Object field as a template
213-
// The name won't match but the infrastructure can work around it
210+
// Use a generic Object field as a template.
211+
// The field name ("property") does not match the actual property name,
212+
// but InterfacePropertyHolder.registerProperty stores the mapping between
213+
// the template field, the actual property name, and the getter method.
214+
// This allows the infrastructure to later retrieve the correct property
215+
// information for interface-based repositories, even though the field name is generic.
214216
Field templateField = InterfacePropertyHolder.class.getDeclaredField("property");
215217
// Store metadata about this field for later use
216218
InterfacePropertyHolder.registerProperty(templateField, propertyName, getterMethod);

0 commit comments

Comments
 (0)