From af7f148f330ff713a31eb33da9e88ce23f35e7a1 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Sun, 8 Jun 2014 14:38:35 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Sjednoceno=20na=C4=8D=C3=ADt=C3=A1n=C3=AD?= =?UTF-8?q?=20n=C3=A1zvu=20entity=20pro=20hibernate.=20Zm=C4=9Bn=C4=9Bn=20?= =?UTF-8?q?u=C5=BEivatel=20pro=20p=C5=99=C3=ADstup=20do=20DB=20z=20admin?= =?UTF-8?q?=20na=20isspt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukova/isspst/dao/jpa/AddressDaoJPA.java | 6 ------ .../info/bukova/isspst/dao/jpa/BaseDaoJPA.java | 16 ++++++++++++++++ .../bukova/isspst/dao/jpa/BuildingDaoJPA.java | 5 ----- .../info/bukova/isspst/dao/jpa/MUnitDaoJPA.java | 5 ----- .../bukova/isspst/dao/jpa/PermissionDaoJPA.java | 6 ------ .../info/bukova/isspst/dao/jpa/RoleDaoJPA.java | 6 ------ .../info/bukova/isspst/dao/jpa/UserDaoJPA.java | 7 ------- src/main/webapp/WEB-INF/jdbc.properties | 2 +- src/main/webapp/WEB-INF/views/home.jsp | 14 -------------- 9 files changed, 17 insertions(+), 50 deletions(-) delete mode 100644 src/main/webapp/WEB-INF/views/home.jsp diff --git a/src/main/java/info/bukova/isspst/dao/jpa/AddressDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/AddressDaoJPA.java index 92f605b5..db3de6fb 100644 --- a/src/main/java/info/bukova/isspst/dao/jpa/AddressDaoJPA.java +++ b/src/main/java/info/bukova/isspst/dao/jpa/AddressDaoJPA.java @@ -4,10 +4,4 @@ import info.bukova.isspst.dao.AddressDao; import info.bukova.isspst.data.Address; public class AddressDaoJPA extends BaseDaoJPA
implements AddressDao { - - @Override - public String getEntityName() { - return Address.class.getSimpleName(); - } - } diff --git a/src/main/java/info/bukova/isspst/dao/jpa/BaseDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/BaseDaoJPA.java index 6a3ef5ba..590ce4bb 100644 --- a/src/main/java/info/bukova/isspst/dao/jpa/BaseDaoJPA.java +++ b/src/main/java/info/bukova/isspst/dao/jpa/BaseDaoJPA.java @@ -4,11 +4,27 @@ import java.util.List; import org.hibernate.Query; import org.hibernate.SessionFactory; +import org.springframework.core.GenericTypeResolver; import info.bukova.isspst.dao.BaseDao; public abstract class BaseDaoJPA implements BaseDao { + protected Class classTypeResolver; + + @SuppressWarnings("unchecked") + public BaseDaoJPA() + { + this.classTypeResolver = (Class) GenericTypeResolver.resolveTypeArgument(getClass(), BaseDaoJPA.class); + } + + @Override + public String getEntityName() { + String className = classTypeResolver.getSimpleName(); + return className; + } + + private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory factory) { diff --git a/src/main/java/info/bukova/isspst/dao/jpa/BuildingDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/BuildingDaoJPA.java index 46a84cfe..7bd93c08 100644 --- a/src/main/java/info/bukova/isspst/dao/jpa/BuildingDaoJPA.java +++ b/src/main/java/info/bukova/isspst/dao/jpa/BuildingDaoJPA.java @@ -4,9 +4,4 @@ import info.bukova.isspst.dao.BuildingDao; import info.bukova.isspst.data.Building; public class BuildingDaoJPA extends BaseDaoJPA implements BuildingDao { - - @Override - public String getEntityName() { - return "Building"; - } } diff --git a/src/main/java/info/bukova/isspst/dao/jpa/MUnitDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/MUnitDaoJPA.java index d91e95ac..fedbe03a 100644 --- a/src/main/java/info/bukova/isspst/dao/jpa/MUnitDaoJPA.java +++ b/src/main/java/info/bukova/isspst/dao/jpa/MUnitDaoJPA.java @@ -4,9 +4,4 @@ import info.bukova.isspst.dao.MUnitDao; import info.bukova.isspst.data.MUnit; public class MUnitDaoJPA extends BaseDaoJPA implements MUnitDao { - - @Override - public String getEntityName() { - return "MUnit"; - } } diff --git a/src/main/java/info/bukova/isspst/dao/jpa/PermissionDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/PermissionDaoJPA.java index a4f7d5ba..5b65247b 100644 --- a/src/main/java/info/bukova/isspst/dao/jpa/PermissionDaoJPA.java +++ b/src/main/java/info/bukova/isspst/dao/jpa/PermissionDaoJPA.java @@ -4,10 +4,4 @@ import info.bukova.isspst.dao.PermissionDao; import info.bukova.isspst.data.Permission; public class PermissionDaoJPA extends BaseDaoJPA implements PermissionDao { - - @Override - public String getEntityName() { - return Permission.class.getSimpleName(); - } - } diff --git a/src/main/java/info/bukova/isspst/dao/jpa/RoleDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/RoleDaoJPA.java index 3fc92974..e5fbae3b 100644 --- a/src/main/java/info/bukova/isspst/dao/jpa/RoleDaoJPA.java +++ b/src/main/java/info/bukova/isspst/dao/jpa/RoleDaoJPA.java @@ -4,10 +4,4 @@ import info.bukova.isspst.dao.RoleDao; import info.bukova.isspst.data.Role; public class RoleDaoJPA extends BaseDaoJPA implements RoleDao { - - @Override - public String getEntityName() { - return "Role"; - } - } diff --git a/src/main/java/info/bukova/isspst/dao/jpa/UserDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/UserDaoJPA.java index b98028fd..06264c78 100644 --- a/src/main/java/info/bukova/isspst/dao/jpa/UserDaoJPA.java +++ b/src/main/java/info/bukova/isspst/dao/jpa/UserDaoJPA.java @@ -4,11 +4,4 @@ import info.bukova.isspst.dao.UserDao; import info.bukova.isspst.data.User; public class UserDaoJPA extends BaseDaoJPA implements UserDao { - - - @Override - public String getEntityName() { - return "User"; - } - } diff --git a/src/main/webapp/WEB-INF/jdbc.properties b/src/main/webapp/WEB-INF/jdbc.properties index e203125f..63673eb4 100644 --- a/src/main/webapp/WEB-INF/jdbc.properties +++ b/src/main/webapp/WEB-INF/jdbc.properties @@ -1,5 +1,5 @@ jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.dialect=org.hibernate.dialect.MySQLDialect jdbc.databaseurl=jdbc:mysql://127.0.0.1:3306/isspst?characterEncoding=latin2 -jdbc.username=root +jdbc.username=isspst jdbc.password=xsacfgd \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/home.jsp b/src/main/webapp/WEB-INF/views/home.jsp deleted file mode 100644 index 47833836..00000000 --- a/src/main/webapp/WEB-INF/views/home.jsp +++ /dev/null @@ -1,14 +0,0 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ page session="false" %> - - - Home - - -

- Hello world! -

- -

The time on the server is ${serverTime}.

- - From c440c65afd2e4081ae2359d11500709bebd29aa6 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Sun, 8 Jun 2014 14:43:20 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Sjednoceno=20na=C4=8D=C3=ADt=C3=A1n=C3=AD?= =?UTF-8?q?=20n=C3=A1zv=C5=AF=20entit=20i=20pro=20ag.=20Materi=C3=A1l.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #96 --- .../java/info/bukova/isspst/dao/jpa/MaterialDaoJPA.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/info/bukova/isspst/dao/jpa/MaterialDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/MaterialDaoJPA.java index 3edeff26..038c5ebe 100644 --- a/src/main/java/info/bukova/isspst/dao/jpa/MaterialDaoJPA.java +++ b/src/main/java/info/bukova/isspst/dao/jpa/MaterialDaoJPA.java @@ -4,11 +4,4 @@ import info.bukova.isspst.dao.MaterialDao; import info.bukova.isspst.data.Material; public class MaterialDaoJPA extends BaseDaoJPA implements MaterialDao { - - @Override - public String getEntityName() { - return Material.class.getSimpleName(); - } - - }