# HG changeset patch # User František Kučera # Date 1237068933 -3600 # Node ID 58552ccfe6c860b31d752baaacc422c21a896fe6 # Parent 7698168255252581b4a074443d40d727711cbb69 Hibernate JPA funguje! Na webu se zobrazuje seznam cílů načtený z databáze: JSP → Webová beana → EJB → JPA → Hibernate → PostgreSQL Jen pozor na správné typy: typ v mapovacím .hbm.xml souboru musí odpovídat typu v databázi, jinak by se aplikace ani nedeploynula a zároveň musíme mít stejný typ v DTO – jinak aplikace padá (při otevření stránky). diff -r 769816825525 -r 58552ccfe6c8 java/HibernateDemo1/HibernateDemo1-lib/src/cz/frantovo/hibernateDemo1/dto/Cil.java --- a/java/HibernateDemo1/HibernateDemo1-lib/src/cz/frantovo/hibernateDemo1/dto/Cil.java Sat Mar 14 22:55:11 2009 +0100 +++ b/java/HibernateDemo1/HibernateDemo1-lib/src/cz/frantovo/hibernateDemo1/dto/Cil.java Sat Mar 14 23:15:33 2009 +0100 @@ -9,16 +9,16 @@ public class Cil implements Serializable { private static final long serialVersionUID = 3789654950408517499L; - private int id; + private long id; private String nazev; private String url; - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } diff -r 769816825525 -r 58552ccfe6c8 java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo/preklady.properties --- a/java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo/preklady.properties Sat Mar 14 22:55:11 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -preklady_cs.properties \ No newline at end of file diff -r 769816825525 -r 58552ccfe6c8 java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo/preklady_cs.properties --- a/java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo/preklady_cs.properties Sat Mar 14 22:55:11 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -nazev=HibernateDemo1 -jazyk=\u010De\u0161tina diff -r 769816825525 -r 58552ccfe6c8 java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo/preklady_en.properties --- a/java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo/preklady_en.properties Sat Mar 14 22:55:11 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -nazev=HibernateDemo1 -jazyk=angli\u010Dtina diff -r 769816825525 -r 58552ccfe6c8 java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo1/SeznamCilu.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo1/SeznamCilu.java Sat Mar 14 23:15:33 2009 +0100 @@ -0,0 +1,38 @@ +package cz.frantovo.hibernateDemo1; + +import cz.frantovo.hibernateDemo1.CilDAORemote; +import cz.frantovo.hibernateDemo1.dto.Cil; +import java.util.Collection; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +/** + * Webová Beana pro zobrazení seznamu cílů. + * Volá EJB, které tento seznam získá z databáze + * @author fiki + */ +public class SeznamCilu { + + private CilDAORemote cilDAO; + private static final Logger log = Logger.getLogger(SeznamCilu.class.getSimpleName()); + + public Collection getCile() { + return lookupCilDAO().getCile(); + } + + private CilDAORemote lookupCilDAO() { + if (cilDAO == null) { + try { + Context c = new InitialContext(); + cilDAO = (CilDAORemote) c.lookup("cz.frantovo.hibernateDemo1.CilDAORemote"); + } catch (NamingException e) { + log.log(Level.SEVERE, "Chyba při hledání CilDAO", e); + throw new RuntimeException(e); + } + } + return cilDAO; + } +} diff -r 769816825525 -r 58552ccfe6c8 java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo1/preklady.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo1/preklady.properties Sat Mar 14 23:15:33 2009 +0100 @@ -0,0 +1,1 @@ +preklady_cs.properties \ No newline at end of file diff -r 769816825525 -r 58552ccfe6c8 java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo1/preklady_cs.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo1/preklady_cs.properties Sat Mar 14 23:15:33 2009 +0100 @@ -0,0 +1,2 @@ +nazev=HibernateDemo1 +jazyk=\u010De\u0161tina diff -r 769816825525 -r 58552ccfe6c8 java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo1/preklady_en.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HibernateDemo1/HibernateDemo1-war/src/java/cz/frantovo/hibernateDemo1/preklady_en.properties Sat Mar 14 23:15:33 2009 +0100 @@ -0,0 +1,2 @@ +nazev=HibernateDemo1 +jazyk=angli\u010Dtina diff -r 769816825525 -r 58552ccfe6c8 java/HibernateDemo1/HibernateDemo1-war/web/WEB-INF/casti/seznamCilu.jspx --- a/java/HibernateDemo1/HibernateDemo1-war/web/WEB-INF/casti/seznamCilu.jspx Sat Mar 14 22:55:11 2009 +0100 +++ b/java/HibernateDemo1/HibernateDemo1-war/web/WEB-INF/casti/seznamCilu.jspx Sat Mar 14 23:15:33 2009 +0100 @@ -1,6 +1,24 @@ - + -

ahoj

+ + +
    + +
  • + + + + + + + + +
  • +
    +
diff -r 769816825525 -r 58552ccfe6c8 java/HibernateDemo1/nbproject/project.properties --- a/java/HibernateDemo1/nbproject/project.properties Sat Mar 14 22:55:11 2009 +0100 +++ b/java/HibernateDemo1/nbproject/project.properties Sat Mar 14 23:15:33 2009 +0100 @@ -4,7 +4,7 @@ client.module.uri=HibernateDemo1-war client.urlPart= debug.classpath=${javac.classpath}::${jar.content.additional}:${run.classpath} -display.browser=true +display.browser=false dist.dir=dist dist.jar=${dist.dir}/${jar.name} j2ee.appclient.mainclass.args=-client ${dist.jar} ${j2ee.appclient.tool.args} @@ -28,4 +28,5 @@ reference.HibernateDemo1-ejb.dist-ear=${project.HibernateDemo1-ejb}/dist/HibernateDemo1-ejb.jar reference.HibernateDemo1-war.dist-ear=${project.HibernateDemo1-war}/dist/HibernateDemo1-war.war resource.dir=setup +run.classpath= source.root=.