1.0.0-SNAPSHOT

This commit is contained in:
insanity 2017-05-26 19:00:36 +09:00
parent c1a1c8f523
commit f60517bbe9
3 changed files with 17 additions and 11 deletions

View File

@ -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<Class> paramTypes = new ArrayList<Class>();
List<Object> valueList = new ArrayList<Object>();
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()]));

View File

@ -9,8 +9,8 @@
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.user" value="vertx" />
<property name="javax.persistence.jdbc.password" value="qwe123" />
<!--<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />-->
<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<!--<property name="hibernate.hbm2ddl.auto" value="create"/>-->
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>

View File

@ -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 {