jdaugherty commented on code in PR #16781:
URL: https://github.com/apache/grails-core/pull/16781#discussion_r4393357784
##########
grails-web-databinding/src/main/groovy/grails/web/databinding/DataBindingUtils.java:
##########
@@ -163,6 +167,56 @@ private static Class bindingType(final Object object) {
return object.getClass();
}
+ private static Class persistentClass(final Object object, final
MappingContext mappingContext) {
+ final ProxyHandler proxyHandler = mappingContext.getProxyHandler();
+ if (proxyHandler != null && proxyHandler.isProxy(object)) {
+ final Class proxiedClass = proxyHandler.getProxiedClass(object);
+ if (proxiedClass != null) {
+ return proxiedClass;
+ }
+ }
+ return object.getClass();
+ }
+
+ /**
+ * The constraints of the persistent entity an object is an instance of,
or a proxy of. The mapping context
+ * evaluates them once, for the validator of the entity, and keeps them
for as long as the entity is mapped,
+ * so binding reads them there rather than evaluating the {@code
constraints} closure of the class again.
+ *
+ * @return the constraints, or {@code null} when the object is not a
mapped entity or its validator does not
+ * expose its constraints
+ */
+ private static Map getEntityConstrainedProperties(final Object object,
final GrailsApplication application) {
+ if (application == null) {
+ return null;
+ }
+ try {
+ final MappingContext mappingContext =
application.getMappingContext();
Review Comment:
@codeconsole do you think this should be fixed as part of this PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]