Fotky se budou zobrazovat v určitém pořadí – podle hodnoty sloupce „poradi“
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 16 Mar 2010 14:33:05 +0100
changeset 7281c64c582a26
parent 71 3829d619369c
child 73 34c7eb5f2fae
Fotky se budou zobrazovat v určitém pořadí – podle hodnoty sloupce „poradi“
Hibernate: Set → List
SQL: podnik a pořadí v tabulce fotek musí být jedinečné
TODO: používat složený klíč?
java/nekurak.net-ejb/src/conf/Fotka.hbm.xml
java/nekurak.net-ejb/src/conf/Podnik.hbm.xml
java/nekurak.net-lib/src/cz/frantovo/nekurak/dto/Fotka.java
java/nekurak.net-lib/src/cz/frantovo/nekurak/dto/Podnik.java
sql/schéma.sql
     1.1 --- a/java/nekurak.net-ejb/src/conf/Fotka.hbm.xml	Tue Mar 16 14:13:14 2010 +0100
     1.2 +++ b/java/nekurak.net-ejb/src/conf/Fotka.hbm.xml	Tue Mar 16 14:33:05 2010 +0100
     1.3 @@ -9,5 +9,6 @@
     1.4  	    </generator>
     1.5  	</id>
     1.6  	<property name="popis" column="popis"/>
     1.7 +	<property name="poradi" column="poradi"/>
     1.8      </class>
     1.9  </hibernate-mapping>
    1.10 \ No newline at end of file
     2.1 --- a/java/nekurak.net-ejb/src/conf/Podnik.hbm.xml	Tue Mar 16 14:13:14 2010 +0100
     2.2 +++ b/java/nekurak.net-ejb/src/conf/Podnik.hbm.xml	Tue Mar 16 14:33:05 2010 +0100
     2.3 @@ -16,10 +16,11 @@
     2.4  	<property name="cisloPopisne" column="cislo_popisne"/>
     2.5  	<property name="mesto" column="mesto"/>
     2.6  	<property name="spravce" column="spravce"/>
     2.7 -	<set name="fotky" table="fotka" lazy="false">
     2.8 +	<list name="fotky" table="fotka" lazy="false">
     2.9  	    <key column="podnik" foreign-key="id"/>
    2.10 +	    <list-index column="poradi"/>
    2.11  	    <one-to-many class="cz.frantovo.nekurak.dto.Fotka"/>
    2.12 -	</set>
    2.13 +	</list>
    2.14  
    2.15      </class>
    2.16  </hibernate-mapping>
    2.17 \ No newline at end of file
     3.1 --- a/java/nekurak.net-lib/src/cz/frantovo/nekurak/dto/Fotka.java	Tue Mar 16 14:13:14 2010 +0100
     3.2 +++ b/java/nekurak.net-lib/src/cz/frantovo/nekurak/dto/Fotka.java	Tue Mar 16 14:33:05 2010 +0100
     3.3 @@ -5,6 +5,7 @@
     3.4      /** číslo odpovídá názvu souboru na disku (+přípona) */
     3.5      private int id;
     3.6      private String popis;
     3.7 +    private int poradi;
     3.8  
     3.9      public int getId() {
    3.10  	return id;
    3.11 @@ -21,4 +22,12 @@
    3.12      public void setPopis(String popis) {
    3.13  	this.popis = popis;
    3.14      }
    3.15 +
    3.16 +    public int getPoradi() {
    3.17 +	return poradi;
    3.18 +    }
    3.19 +
    3.20 +    public void setPoradi(int poradi) {
    3.21 +	this.poradi = poradi;
    3.22 +    }
    3.23  }
     4.1 --- a/java/nekurak.net-lib/src/cz/frantovo/nekurak/dto/Podnik.java	Tue Mar 16 14:13:14 2010 +0100
     4.2 +++ b/java/nekurak.net-lib/src/cz/frantovo/nekurak/dto/Podnik.java	Tue Mar 16 14:33:05 2010 +0100
     4.3 @@ -1,8 +1,9 @@
     4.4  package cz.frantovo.nekurak.dto;
     4.5  
     4.6  import java.io.Serializable;
     4.7 +import java.util.ArrayList;
     4.8  import java.util.Date;
     4.9 -import java.util.HashSet;
    4.10 +import java.util.List;
    4.11  import java.util.Set;
    4.12  
    4.13  /**
    4.14 @@ -20,7 +21,7 @@
    4.15      private int cisloPopisne;
    4.16      private String mesto;
    4.17      private String spravce;
    4.18 -    private Set<Fotka> fotky = new HashSet<Fotka>();
    4.19 +    private List<Fotka> fotky = new ArrayList<Fotka>();
    4.20  
    4.21      public Podnik() {
    4.22      }
    4.23 @@ -102,11 +103,11 @@
    4.24  	this.spravce = spravce;
    4.25      }
    4.26  
    4.27 -    public Set<Fotka> getFotky() {
    4.28 +    public List<Fotka> getFotky() {
    4.29  	return fotky;
    4.30      }
    4.31  
    4.32 -    public void setFotky(Set<Fotka> fotky) {
    4.33 +    public void setFotky(List<Fotka> fotky) {
    4.34  	this.fotky = fotky;
    4.35      }
    4.36  }
     5.1 --- a/sql/schéma.sql	Tue Mar 16 14:13:14 2010 +0100
     5.2 +++ b/sql/schéma.sql	Tue Mar 16 14:33:05 2010 +0100
     5.3 @@ -2,7 +2,7 @@
     5.4  -- PostgreSQL database dump
     5.5  --
     5.6  
     5.7 --- Started on 2010-03-16 14:11:16 CET
     5.8 +-- Started on 2010-03-16 14:32:22 CET
     5.9  
    5.10  SET statement_timeout = 0;
    5.11  SET client_encoding = 'UTF8';
    5.12 @@ -36,7 +36,7 @@
    5.13  ALTER DOMAIN nekurak.email OWNER TO nekurak;
    5.14  
    5.15  --
    5.16 --- TOC entry 1892 (class 0 OID 0)
    5.17 +-- TOC entry 1894 (class 0 OID 0)
    5.18  -- Dependencies: 368
    5.19  -- Name: DOMAIN email; Type: COMMENT; Schema: nekurak; Owner: nekurak
    5.20  --
    5.21 @@ -46,7 +46,7 @@
    5.22  
    5.23  --
    5.24  -- TOC entry 65 (class 1255 OID 35124)
    5.25 --- Dependencies: 395 10
    5.26 +-- Dependencies: 10 395
    5.27  -- Name: bezny_uzivatel(); Type: FUNCTION; Schema: nekurak; Owner: nekurak
    5.28  --
    5.29  
    5.30 @@ -64,7 +64,7 @@
    5.31  ALTER FUNCTION nekurak.bezny_uzivatel() OWNER TO nekurak;
    5.32  
    5.33  --
    5.34 --- TOC entry 1893 (class 0 OID 0)
    5.35 +-- TOC entry 1895 (class 0 OID 0)
    5.36  -- Dependencies: 65
    5.37  -- Name: FUNCTION bezny_uzivatel(); Type: COMMENT; Schema: nekurak; Owner: nekurak
    5.38  --
    5.39 @@ -109,7 +109,7 @@
    5.40  ALTER TABLE nekurak.fotka OWNER TO nekurak;
    5.41  
    5.42  --
    5.43 --- TOC entry 1895 (class 0 OID 0)
    5.44 +-- TOC entry 1897 (class 0 OID 0)
    5.45  -- Dependencies: 1593
    5.46  -- Name: TABLE fotka; Type: COMMENT; Schema: nekurak; Owner: nekurak
    5.47  --
    5.48 @@ -118,7 +118,7 @@
    5.49  
    5.50  
    5.51  --
    5.52 --- TOC entry 1896 (class 0 OID 0)
    5.53 +-- TOC entry 1898 (class 0 OID 0)
    5.54  -- Dependencies: 1593
    5.55  -- Name: COLUMN fotka.poradi; Type: COMMENT; Schema: nekurak; Owner: nekurak
    5.56  --
    5.57 @@ -145,7 +145,7 @@
    5.58  ALTER TABLE nekurak.hlasovani OWNER TO nekurak;
    5.59  
    5.60  --
    5.61 --- TOC entry 1898 (class 0 OID 0)
    5.62 +-- TOC entry 1900 (class 0 OID 0)
    5.63  -- Dependencies: 1587
    5.64  -- Name: COLUMN hlasovani.hlas; Type: COMMENT; Schema: nekurak; Owner: nekurak
    5.65  --
    5.66 @@ -194,7 +194,7 @@
    5.67  ALTER TABLE nekurak.podnik OWNER TO nekurak;
    5.68  
    5.69  --
    5.70 --- TOC entry 1901 (class 0 OID 0)
    5.71 +-- TOC entry 1903 (class 0 OID 0)
    5.72  -- Dependencies: 1586
    5.73  -- Name: COLUMN podnik.spravce; Type: COMMENT; Schema: nekurak; Owner: nekurak
    5.74  --
    5.75 @@ -217,7 +217,7 @@
    5.76  ALTER TABLE nekurak.role OWNER TO nekurak;
    5.77  
    5.78  --
    5.79 --- TOC entry 1903 (class 0 OID 0)
    5.80 +-- TOC entry 1905 (class 0 OID 0)
    5.81  -- Dependencies: 1590
    5.82  -- Name: TABLE role; Type: COMMENT; Schema: nekurak; Owner: nekurak
    5.83  --
    5.84 @@ -260,7 +260,7 @@
    5.85  ALTER TABLE nekurak.uzivatel OWNER TO nekurak;
    5.86  
    5.87  --
    5.88 --- TOC entry 1906 (class 0 OID 0)
    5.89 +-- TOC entry 1908 (class 0 OID 0)
    5.90  -- Dependencies: 1589
    5.91  -- Name: COLUMN uzivatel.prezdivka; Type: COMMENT; Schema: nekurak; Owner: nekurak
    5.92  --
    5.93 @@ -283,7 +283,7 @@
    5.94  ALTER TABLE nekurak.uzivatel_role OWNER TO nekurak;
    5.95  
    5.96  --
    5.97 --- TOC entry 1908 (class 0 OID 0)
    5.98 +-- TOC entry 1910 (class 0 OID 0)
    5.99  -- Dependencies: 1591
   5.100  -- Name: TABLE uzivatel_role; Type: COMMENT; Schema: nekurak; Owner: nekurak
   5.101  --
   5.102 @@ -302,6 +302,16 @@
   5.103  
   5.104  
   5.105  --
   5.106 +-- TOC entry 1884 (class 2606 OID 35204)
   5.107 +-- Dependencies: 1593 1593 1593
   5.108 +-- Name: fotka_poradi_uq; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
   5.109 +--
   5.110 +
   5.111 +ALTER TABLE ONLY fotka
   5.112 +    ADD CONSTRAINT fotka_poradi_uq UNIQUE (popis, poradi);
   5.113 +
   5.114 +
   5.115 +--
   5.116  -- TOC entry 1872 (class 2606 OID 35058)
   5.117  -- Dependencies: 1586 1586
   5.118  -- Name: podnik_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
   5.119 @@ -352,8 +362,8 @@
   5.120  
   5.121  
   5.122  --
   5.123 --- TOC entry 1888 (class 2620 OID 35125)
   5.124 --- Dependencies: 65 1589
   5.125 +-- TOC entry 1890 (class 2620 OID 35125)
   5.126 +-- Dependencies: 1589 65
   5.127  -- Name: uzivatel_insert; Type: TRIGGER; Schema: nekurak; Owner: nekurak
   5.128  --
   5.129  
   5.130 @@ -364,8 +374,8 @@
   5.131  
   5.132  
   5.133  --
   5.134 --- TOC entry 1887 (class 2606 OID 35191)
   5.135 --- Dependencies: 1871 1593 1586
   5.136 +-- TOC entry 1889 (class 2606 OID 35191)
   5.137 +-- Dependencies: 1871 1586 1593
   5.138  -- Name: fotka_podnik_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
   5.139  --
   5.140  
   5.141 @@ -374,8 +384,8 @@
   5.142  
   5.143  
   5.144  --
   5.145 --- TOC entry 1884 (class 2606 OID 35072)
   5.146 --- Dependencies: 1871 1586 1587
   5.147 +-- TOC entry 1886 (class 2606 OID 35072)
   5.148 +-- Dependencies: 1587 1871 1586
   5.149  -- Name: hlasovani_podnik_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
   5.150  --
   5.151  
   5.152 @@ -384,7 +394,7 @@
   5.153  
   5.154  
   5.155  --
   5.156 --- TOC entry 1883 (class 2606 OID 35178)
   5.157 +-- TOC entry 1885 (class 2606 OID 35178)
   5.158  -- Dependencies: 1875 1589 1586
   5.159  -- Name: podnik_uzivatel_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
   5.160  --
   5.161 @@ -394,7 +404,7 @@
   5.162  
   5.163  
   5.164  --
   5.165 --- TOC entry 1885 (class 2606 OID 35138)
   5.166 +-- TOC entry 1887 (class 2606 OID 35138)
   5.167  -- Dependencies: 1590 1591 1877
   5.168  -- Name: uzivatel_role_role_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
   5.169  --
   5.170 @@ -404,7 +414,7 @@
   5.171  
   5.172  
   5.173  --
   5.174 --- TOC entry 1886 (class 2606 OID 35143)
   5.175 +-- TOC entry 1888 (class 2606 OID 35143)
   5.176  -- Dependencies: 1591 1589 1875
   5.177  -- Name: uzivatel_role_uzivatel_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
   5.178  --
   5.179 @@ -414,7 +424,7 @@
   5.180  
   5.181  
   5.182  --
   5.183 --- TOC entry 1891 (class 0 OID 0)
   5.184 +-- TOC entry 1893 (class 0 OID 0)
   5.185  -- Dependencies: 10
   5.186  -- Name: nekurak; Type: ACL; Schema: -; Owner: nekurak
   5.187  --
   5.188 @@ -426,7 +436,7 @@
   5.189  
   5.190  
   5.191  --
   5.192 --- TOC entry 1894 (class 0 OID 0)
   5.193 +-- TOC entry 1896 (class 0 OID 0)
   5.194  -- Dependencies: 1592
   5.195  -- Name: fotka_seq; Type: ACL; Schema: nekurak; Owner: nekurak
   5.196  --
   5.197 @@ -438,7 +448,7 @@
   5.198  
   5.199  
   5.200  --
   5.201 --- TOC entry 1897 (class 0 OID 0)
   5.202 +-- TOC entry 1899 (class 0 OID 0)
   5.203  -- Dependencies: 1593
   5.204  -- Name: fotka; Type: ACL; Schema: nekurak; Owner: nekurak
   5.205  --
   5.206 @@ -450,7 +460,7 @@
   5.207  
   5.208  
   5.209  --
   5.210 --- TOC entry 1899 (class 0 OID 0)
   5.211 +-- TOC entry 1901 (class 0 OID 0)
   5.212  -- Dependencies: 1587
   5.213  -- Name: hlasovani; Type: ACL; Schema: nekurak; Owner: nekurak
   5.214  --
   5.215 @@ -462,7 +472,7 @@
   5.216  
   5.217  
   5.218  --
   5.219 --- TOC entry 1900 (class 0 OID 0)
   5.220 +-- TOC entry 1902 (class 0 OID 0)
   5.221  -- Dependencies: 1585
   5.222  -- Name: podnik_seq; Type: ACL; Schema: nekurak; Owner: nekurak
   5.223  --
   5.224 @@ -474,7 +484,7 @@
   5.225  
   5.226  
   5.227  --
   5.228 --- TOC entry 1902 (class 0 OID 0)
   5.229 +-- TOC entry 1904 (class 0 OID 0)
   5.230  -- Dependencies: 1586
   5.231  -- Name: podnik; Type: ACL; Schema: nekurak; Owner: nekurak
   5.232  --
   5.233 @@ -486,7 +496,7 @@
   5.234  
   5.235  
   5.236  --
   5.237 --- TOC entry 1904 (class 0 OID 0)
   5.238 +-- TOC entry 1906 (class 0 OID 0)
   5.239  -- Dependencies: 1590
   5.240  -- Name: role; Type: ACL; Schema: nekurak; Owner: nekurak
   5.241  --
   5.242 @@ -498,7 +508,7 @@
   5.243  
   5.244  
   5.245  --
   5.246 --- TOC entry 1905 (class 0 OID 0)
   5.247 +-- TOC entry 1907 (class 0 OID 0)
   5.248  -- Dependencies: 1588
   5.249  -- Name: uzivatel_seq; Type: ACL; Schema: nekurak; Owner: nekurak
   5.250  --
   5.251 @@ -510,7 +520,7 @@
   5.252  
   5.253  
   5.254  --
   5.255 --- TOC entry 1907 (class 0 OID 0)
   5.256 +-- TOC entry 1909 (class 0 OID 0)
   5.257  -- Dependencies: 1589
   5.258  -- Name: uzivatel; Type: ACL; Schema: nekurak; Owner: nekurak
   5.259  --
   5.260 @@ -522,7 +532,7 @@
   5.261  
   5.262  
   5.263  --
   5.264 --- TOC entry 1909 (class 0 OID 0)
   5.265 +-- TOC entry 1911 (class 0 OID 0)
   5.266  -- Dependencies: 1591
   5.267  -- Name: uzivatel_role; Type: ACL; Schema: nekurak; Owner: nekurak
   5.268  --
   5.269 @@ -533,7 +543,7 @@
   5.270  GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE uzivatel_role TO nekurak_web;
   5.271  
   5.272  
   5.273 --- Completed on 2010-03-16 14:11:18 CET
   5.274 +-- Completed on 2010-03-16 14:32:24 CET
   5.275  
   5.276  --
   5.277  -- PostgreSQL database dump complete