Introduce argeo server hibernate
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 13 Oct 2009 17:25:55 +0000 (17:25 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 13 Oct 2009 17:25:55 +0000 (17:25 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@3024 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

server/runtime/org.argeo.server.hibernate/src/main/java/org/argeo/server/hibernate/LightDaoInterceptor.java

index 9f3ba093d1497af291a970e7d35320b930bb8a28..3bb13f37d97a66178c887b992c525b84cdaf3fc8 100644 (file)
@@ -35,15 +35,24 @@ public class LightDaoInterceptor extends EmptyInterceptor {
        @Override
        public Object getEntity(String entityName, Serializable id) {
                Class<?> clss = findSupportingClass(entityName);
+               Object res = null;
                if (clss != null) {
-                       if (businessIdFields.containsKey(clss))
-                               return lightDaoSupport.getByField(clss, businessIdFields
-                                               .get(clss), bidMappings.get(clss).get(id));
-                       else
-                               return lightDaoSupport.getByKey(clss, id);
+                       if (businessIdFields.containsKey(clss)) {
+                               String field = businessIdFields.get(clss);
+                               Object value = bidMappings.get(clss).get(id);
+                               res = lightDaoSupport.getByField(clss, field, value);
+                               if (log.isDebugEnabled())
+                                       log.debug("Got entity " + clss + " (" + field + "=" + value
+                                                       + ")");
+                       } else {
+                               res = lightDaoSupport.getByKey(clss, id);
+                               if (log.isDebugEnabled())
+                                       log.debug("Got entity " + clss + " (id=" + id + ")");
+                       }
                } else {
-                       return super.getEntity(entityName, id);
+                       res = super.getEntity(entityName, id);
                }
+               return res;
        }
 
        @Override