# HG changeset patch
# User Asier Lostalé <asier.lostale@openbravo.com>
# Date 1464959768 -7200
#      Fri Jun 03 15:16:08 2016 +0200
# Node ID 7f8a9f2134c1b9ed6f25db0689acf544ca564dd6
# Parent  5c3ae208fb2c59fc17b2ced22a80a0c2813ec72f
playing with proxies

diff -r 5c3ae208fb2c -r 7f8a9f2134c1 src/org/openbravo/dal/core/OBDynamicPropertyHandler.java
--- a/src/org/openbravo/dal/core/OBDynamicPropertyHandler.java	Fri Jun 03 13:58:10 2016 +0200
+++ b/src/org/openbravo/dal/core/OBDynamicPropertyHandler.java	Fri Jun 03 15:16:08 2016 +0200
@@ -39,23 +39,35 @@
 @SuppressWarnings("rawtypes")
 public class OBDynamicPropertyHandler implements PropertyAccessor {
   public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException {
-    return new Getter(NamingUtil.getStaticPropertyName(theClass, propertyName));
+    return new Getter(theClass, propertyName);
   }
 
   public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException {
-    return new Setter(NamingUtil.getStaticPropertyName(theClass, propertyName));
+    return new Setter(theClass, propertyName);
   }
 
   public static class Getter implements org.hibernate.property.Getter {
     private static final long serialVersionUID = 1L;
+    private static final String ID_GETTER = "getId";
 
     private String propertyName;
+    private Class theClass;
 
-    public Getter(String propertyName) {
-      this.propertyName = propertyName;
+    public Getter(Class theClass, String propertyName) {
+      this.theClass = theClass;
+      this.propertyName = NamingUtil.getStaticPropertyName(theClass, propertyName);
     }
 
+    @SuppressWarnings("unchecked")
     public Method getMethod() {
+      if (BaseOBObject.ID.equals(this.propertyName)) {
+        try {
+          return theClass.getDeclaredMethod(ID_GETTER);
+        } catch (NoSuchMethodException e) {
+        } catch (SecurityException e) {
+        }
+      }
+
       return null;
     }
 
@@ -83,14 +95,26 @@
 
   public static class Setter implements org.hibernate.property.Setter {
     private static final long serialVersionUID = 1L;
+    private static final String ID_SETTER = "setId";
 
     private String propertyName;
+    private Class theClass;
 
-    public Setter(String propertyName) {
-      this.propertyName = propertyName;
+    public Setter(Class theClass, String propertyName) {
+      this.theClass = theClass;
+      this.propertyName = NamingUtil.getStaticPropertyName(theClass, propertyName);
     }
 
+    @SuppressWarnings("unchecked")
     public Method getMethod() {
+      if (BaseOBObject.ID.equals(this.propertyName)) {
+        try {
+          return theClass.getDeclaredMethod(ID_SETTER, String.class);
+        } catch (NoSuchMethodException e) {
+        } catch (SecurityException e) {
+        }
+      }
+
       return null;
     }
 
