author | František Kučera <franta-hg@frantovo.cz> |
Wed Feb 10 20:55:08 2010 +0100 (2010-02-10) | |
changeset 1 | 9a3fced9634d |
child 2 | d549a4eb6aa9 |
permissions | -rw-r--r-- |
franta-hg@1 | 1 |
package cz.frantovo.springDemo1.dao; |
franta-hg@1 | 2 |
|
franta-hg@1 | 3 |
import cz.frantovo.springDemo1.dto.Kniha; |
franta-hg@1 | 4 |
import java.util.ArrayList; |
franta-hg@1 | 5 |
import java.util.Collection; |
franta-hg@1 | 6 |
import javax.annotation.Resource; |
franta-hg@1 | 7 |
import javax.sql.DataSource; |
franta-hg@1 | 8 |
import org.springframework.jdbc.core.JdbcTemplate; |
franta-hg@1 | 9 |
import org.springframework.stereotype.Repository; |
franta-hg@1 | 10 |
|
franta-hg@1 | 11 |
/** |
franta-hg@1 | 12 |
* |
franta-hg@1 | 13 |
* @author fiki |
franta-hg@1 | 14 |
*/ |
franta-hg@1 | 15 |
@Repository("knihaDAO") |
franta-hg@1 | 16 |
public class KnihaDAO { |
franta-hg@1 | 17 |
|
franta-hg@1 | 18 |
private DataSource dataSource; |
franta-hg@1 | 19 |
|
franta-hg@1 | 20 |
@Resource |
franta-hg@1 | 21 |
public void setDataSource(DataSource dataSource) { |
franta-hg@1 | 22 |
this.dataSource = dataSource; |
franta-hg@1 | 23 |
} |
franta-hg@1 | 24 |
|
franta-hg@1 | 25 |
public Collection<Kniha> getKnihy() { |
franta-hg@1 | 26 |
Collection<Kniha> vysledek = new ArrayList<Kniha>(); |
franta-hg@1 | 27 |
|
franta-hg@1 | 28 |
JdbcTemplate t = new JdbcTemplate(dataSource); |
franta-hg@1 | 29 |
|
franta-hg@1 | 30 |
t.queryForInt("SELECT 1;"); |
franta-hg@1 | 31 |
|
franta-hg@1 | 32 |
Kniha k = new Kniha(); |
franta-hg@1 | 33 |
k.setNazev("Pokusná kniha"); |
franta-hg@1 | 34 |
vysledek.add(k); |
franta-hg@1 | 35 |
|
franta-hg@1 | 36 |
return vysledek; |
franta-hg@1 | 37 |
} |
franta-hg@1 | 38 |
} |