author | František Kučera <franta-hg@frantovo.cz> |
Thu, 11 Feb 2010 23:16:43 +0100 | |
changeset 6 | 0ae95f929a1a |
parent 4 | 85754d201c93 |
permissions | -rw-r--r-- |
franta-hg@1 | 1 |
package cz.frantovo.springDemo1.dao; |
franta-hg@1 | 2 |
|
franta-hg@2 | 3 |
import cz.frantovo.springDemo1.KnihaDAORemote; |
franta-hg@1 | 4 |
import cz.frantovo.springDemo1.dto.Kniha; |
franta-hg@1 | 5 |
import java.util.Collection; |
franta-hg@1 | 6 |
import javax.annotation.Resource; |
franta-hg@2 | 7 |
import javax.ejb.Stateless; |
franta-hg@1 | 8 |
import javax.sql.DataSource; |
franta-hg@1 | 9 |
import org.springframework.jdbc.core.JdbcTemplate; |
franta-hg@1 | 10 |
|
franta-hg@1 | 11 |
/** |
franta-hg@6 | 12 |
* Pro zjednodušení bez <a href="http://hg.frantovo.cz/SuperDAO/">SuperDao</a>. |
franta-hg@1 | 13 |
* @author fiki |
franta-hg@1 | 14 |
*/ |
franta-hg@2 | 15 |
@Stateless |
franta-hg@2 | 16 |
public class KnihaDAO implements KnihaDAORemote { |
franta-hg@1 | 17 |
|
franta-hg@3 | 18 |
@Resource(mappedName = "jdbc/sqlVyuka/piskoviste") |
franta-hg@1 | 19 |
private DataSource dataSource; |
franta-hg@4 | 20 |
private KnihaRowMapper knihaRowMapper = new KnihaRowMapper(); |
franta-hg@6 | 21 |
JdbcTemplate t = new JdbcTemplate(dataSource); |
franta-hg@1 | 22 |
|
franta-hg@1 | 23 |
public Collection<Kniha> getKnihy() { |
franta-hg@4 | 24 |
return t.query("SELECT * FROM sbirka.kniha;", knihaRowMapper); |
franta-hg@1 | 25 |
} |
franta-hg@6 | 26 |
|
franta-hg@6 | 27 |
public int ulozKnihu(Kniha k) { |
franta-hg@6 | 28 |
return t.update("UPDATE kniha SET (nazev, autor, datum, isbn, pocet_stran, rok_vydani, id) VALUES (?,?,?,?,?,?,?)", new KnihaPSSetter(k)); |
franta-hg@6 | 29 |
} |
franta-hg@1 | 30 |
} |