diff --git a/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java b/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java index 8c1935c..f4cf667 100644 --- a/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java +++ b/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java @@ -93,6 +93,15 @@ public class DBProxy { ObjectMapper mapper = new ObjectMapper(); + Object retObj = null; + Method method = null; + + if (methodName.equals("find")) { + method = dao.getClass().getSuperclass().getMethod(methodName, String.class); + retObj = method.invoke(dao, params.get("id")); + return mapper.writeValueAsString(retObj); + } + List paramTypes = new ArrayList(); List valueList = new ArrayList(); for( String className : params.keySet() ){ @@ -103,15 +112,11 @@ public class DBProxy { paramTypes.add(cls); } - Object retObj = null; - Method method = null; - try { //Check if it belongs to the JPABaseDAO. method = dao.getClass().getSuperclass().getMethod(methodName, Object.class); - if(method != null) { - retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()])); - } + retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()])); + }catch(NoSuchMethodException e) { if(params.size() > 0) { method = dao.getClass().getMethod(methodName, paramTypes.toArray(new Class[paramTypes.size()])); diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 60d083b..9d060aa 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -9,8 +9,8 @@ - - + + diff --git a/src/test/java/com/loafle/TestClient.java b/src/test/java/com/loafle/TestClient.java index 2b8e27c..199223a 100644 --- a/src/test/java/com/loafle/TestClient.java +++ b/src/test/java/com/loafle/TestClient.java @@ -37,7 +37,8 @@ public class TestClient { try { Member m = new Member(); - m.setName("insanity2222"); + m.setId(Long.parseLong("2")); + m.setName("geek"); m.setCompany("loafle"); m.setDigest("bbbbbbbbb"); m.setPwSalt("salktttt"); @@ -47,9 +48,9 @@ public class TestClient { DBInput request = DBInput.newBuilder() .setTargetDao("member") - .setMethod("create") + .setMethod("findByEmail") .putParams("com.loafle.overflow.member.model.Member", mapper.writeValueAsString(m)) - //.putParams("com.loafle.overflow.member.Member2", mapper.writeValueAsString(m2)) + //.putParams("id", "1") .build(); DBOutput response; try {