JPA: persistence.xml a první mapování
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 14 Mar 2009 22:14:59 +0100
changeset 155b52df32ec2
parent 0 16a1fc2116d6
child 2 715acc59d67d
JPA: persistence.xml a první mapování
java/HibernateDemo1/HibernateDemo1-ejb/src/conf/Cil.hbm.xml
java/HibernateDemo1/HibernateDemo1-ejb/src/conf/persistence.xml
java/HibernateDemo1/HibernateDemo1-ejb/src/java/cz/frantovo/hibernateDemo1/CilDAOBean.java
java/HibernateDemo1/HibernateDemo1-lib/src/cz/frantovo/hibernateDemo1/CilDAORemote.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/java/HibernateDemo1/HibernateDemo1-ejb/src/conf/Cil.hbm.xml	Sat Mar 14 22:14:59 2009 +0100
     1.3 @@ -0,0 +1,11 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<!DOCTYPE hibernate-mapping PUBLIC
     1.6 +        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
     1.7 +        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
     1.8 +<hibernate-mapping>
     1.9 +    <class name="cz.frantovo.hibernateDemo1.dto.Cil" table="cil">
    1.10 +        <id name="id" column="id"/>
    1.11 +        <property name="nazev" column="nazev"/>
    1.12 +        <property name="url" column="url"/>
    1.13 +    </class>
    1.14 +</hibernate-mapping>
    1.15 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/java/HibernateDemo1/HibernateDemo1-ejb/src/conf/persistence.xml	Sat Mar 14 22:14:59 2009 +0100
     2.3 @@ -0,0 +1,19 @@
     2.4 +<?xml version="1.0" encoding="UTF-8"?>
     2.5 +<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
     2.6 +    <persistence-unit name="POSZ-ejbPU" transaction-type="JTA">
     2.7 +        <provider>org.hibernate.ejb.HibernatePersistence</provider>
     2.8 +        <jta-data-source>jdbc/hrisnicispameri</jta-data-source>
     2.9 +        <exclude-unlisted-classes>false</exclude-unlisted-classes>
    2.10 +        <properties>
    2.11 +            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
    2.12 +            <property name="hibernate.hbm2ddl.auto" value="create" />
    2.13 +            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" />
    2.14 +            <property name="hibernate.cache.use_query_cache" value="true" />
    2.15 +            <property name="hibernate.max_fetch_depth " value="3" />
    2.16 +            <property name="hibernate.default_batch_fetch_size" value="16" />
    2.17 +            <property name="hibernate.order_updates" value="true" />
    2.18 +            <property name="hibernate.order_inserts" value="true" />
    2.19 +            <property name="hibernate.show_sql" value="false"/>
    2.20 +        </properties>
    2.21 +    </persistence-unit>
    2.22 +</persistence>
    2.23 \ No newline at end of file
     3.1 --- a/java/HibernateDemo1/HibernateDemo1-ejb/src/java/cz/frantovo/hibernateDemo1/CilDAOBean.java	Sat Mar 14 21:58:41 2009 +0100
     3.2 +++ b/java/HibernateDemo1/HibernateDemo1-ejb/src/java/cz/frantovo/hibernateDemo1/CilDAOBean.java	Sat Mar 14 22:14:59 2009 +0100
     3.3 @@ -1,10 +1,7 @@
     3.4 -/*
     3.5 - * To change this template, choose Tools | Templates
     3.6 - * and open the template in the editor.
     3.7 - */
     3.8 -
     3.9  package cz.frantovo.hibernateDemo1;
    3.10  
    3.11 +import cz.frantovo.hibernateDemo1.dto.Cil;
    3.12 +import java.util.Collection;
    3.13  import javax.ejb.Stateless;
    3.14  
    3.15  /**
    3.16 @@ -13,8 +10,10 @@
    3.17   */
    3.18  @Stateless
    3.19  public class CilDAOBean implements CilDAORemote {
    3.20 +
    3.21 +    public Collection<Cil> getCile() {
    3.22 +        throw new UnsupportedOperationException("Not supported yet.");
    3.23 +    }
    3.24      
    3.25 -    // Add business logic below. (Right-click in editor and choose
    3.26 -    // "Insert Code > Add Business Method" or "Web Service > Add Operation")
    3.27   
    3.28  }
     4.1 --- a/java/HibernateDemo1/HibernateDemo1-lib/src/cz/frantovo/hibernateDemo1/CilDAORemote.java	Sat Mar 14 21:58:41 2009 +0100
     4.2 +++ b/java/HibernateDemo1/HibernateDemo1-lib/src/cz/frantovo/hibernateDemo1/CilDAORemote.java	Sat Mar 14 22:14:59 2009 +0100
     4.3 @@ -1,10 +1,7 @@
     4.4 -/*
     4.5 - * To change this template, choose Tools | Templates
     4.6 - * and open the template in the editor.
     4.7 - */
     4.8 -
     4.9  package cz.frantovo.hibernateDemo1;
    4.10  
    4.11 +import cz.frantovo.hibernateDemo1.dto.Cil;
    4.12 +import java.util.Collection;
    4.13  import javax.ejb.Remote;
    4.14  
    4.15  /**
    4.16 @@ -13,5 +10,6 @@
    4.17   */
    4.18  @Remote
    4.19  public interface CilDAORemote {
    4.20 -    
    4.21 +
    4.22 +    public Collection<Cil> getCile();
    4.23  }