Thorsten Kraus wrote:
Can't help you with one, but with 2, it works for ME!

create a context.xml  file in your META-INT like
======================================

<!-- Connection details for Hibernate
    NOTE This isntace is readonly
 -->
<Context>
       <Resource name="jdbc/castleDB" auth="Container"
           type="javax.sql.DataSource" username="data_user" password=""
           driverClassName="org.postgresql.Driver"
           url="jdbc:postgresql://127.0.0.1/castle"
           maxActive="8"
           maxIdle="4" />


</Context>
===============
Put the hibernate config file in webapps/mma/WEB-INF/classes
================
<hibernate-configuration>

       <!-- a SessionFactory instance listed as /jndi/name -->
       <session-factory>

               <!-- properties -->
<property name="connection.datasource">java:/comp/env/jdbc/castleDB</property> <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
               <property name="show_sql">true</property>
               <property name="use_outer_join">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

               <property name="generate_statistics">true</property>
               <property name="cache.use_query_cache">false</property>
               <property name="cache.use_minimal_puts">false</property>
<property name="current_session_context_class">thread</property>
               <property name="max_fetch_depth">3</property>
               <property name="c3p0.min_size">3</property>
               <property name="c3p0.max_size">5</property>
               <property name="c3p0.timeout">1800</property>

               <!-- mapping files -->
               <mapping resource="uk/co/pinan/mma/dto/CountyDTO.hbm.xml"/>
               <mapping resource="uk/co/pinan/mma/dto/CastleDTO.hbm.xml"/>
<mapping resource="uk/co/pinan/mma/dto/OwnerMapDTO.hbm.xml"/> <mapping resource="uk/co/pinan/mma/dto/PlaceNameDTO.hbm.xml"/>
               <mapping resource="uk/co/pinan/mma/dto/OwnerDTO.hbm.xml"/>
               <mapping resource="uk/co/pinan/mma/dto/HundredDTO.hbm.xml"/>
               <mapping resource="uk/co/pinan/mma/dto/PlaceDTO.hbm.xml"/>
       </session-factory>

</hibernate-configuration>
==========================
And use something like to map your files
======================

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>

<hibernate-mapping
>
   <class
       name="uk.co.pinan.mma.dto.OwnerDTO"
       table="owner_table"
   >

       <id
           name="ownerId"
           column="owner_id"
           type="int"
       >
           <generator class="native">
             <!--
To add non XDoclet generator parameters, create a file named
                 hibernate-generator-params-OwnerDTO.xml
containing the additional parameters and place it in your merge dir.
             -->
           </generator>
       </id>

       <property
           name="ownerName"
           type="text"
           update="true"
           insert="true"
           column="owner_name"
       />

       <property
           name="churchman"
           type="boolean"
           update="true"
           insert="true"
           column="churchman"
       />

       <!--
           To add non XDoclet property mappings, create a file named
               hibernate-properties-OwnerDTO.xml
containing the additional properties and place it in your merge dir.
       -->

   </class>

</hibernate-mapping>
Hi Andy,
thanks for this useful information. I read the ejb3spatial.pdf and have some further questions on this topic :) 1. You mentioned that Norman Barker has created a user type for Hibernate. Is this user type an official component of the Hibernate framework or is it an addition where no support from the Hibernate team is guaranteed? 2. The tutorial in the pdf uses JBoss as application server. In my project I use Tomcat. So Tomcat is not a full application server, I think it is not possible to use Hibernate for PostGIS access in my project without changing the application server. Is this right? Thanks,
Thorsten

    -----Ursprüngliche Nachricht-----
    *Von:* [EMAIL PROTECTED]
    [mailto:[EMAIL PROTECTED] Auftrag
    von *Andy Dale
    *Gesendet:* Freitag, 27. Juli 2007 09:10
    *An:* PostGIS Users Discussion
    *Betreff:* Re: [postgis-users] PostGIS and Hibernate

    Hi Thorsten,

    A person called Norman Barker has created a user type for
    Hibernate, this can be accessed here
    http://svn.refractions.net/postgis/trunk/java/ejb3/
    <http://svn.refractions.net/postgis/trunk/java/ejb3/>also read the
    ejb3spatial.pdf located here as it gives a example of how to use it.

    Cheers,

    Andy



    On 27/07/07, *Thorsten Kraus* < [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>> wrote:

        Hi all,

        currently I am working for a project which uses PostGIS to
        store spatial objects in the backend of an web application
        (Tomcat is used as servlet container). Some time ago I
        searched the web for Hibernate support for PostGIS database
        and its geographical objects, but found nothing suitable. So I
        use Hibernate for non geographical attribute data and wrote
        some JDBC code for accessing the geographical objects in
        PostGIS. This hybrid structure of Hibernate and JDBC works
        fine, but it would even be nicer and more flexible if there
        was a possibility to handle all the database stuff with
        Hibernate.

        Can you tell me if there is Hibernate support for PostGIS
        meanwhile? If yes, a piece of code or a link to a tutorial
        would be pleasant.

        Kind regards,
        Thorsten


        _______________________________________________
        postgis-users mailing list
        [email protected]
        <mailto:[email protected]>
        http://postgis.refractions.net/mailman/listinfo/postgis-users


------------------------------------------------------------------------

_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

begin:vcard
fn:David Potts
n:Potts;David
x-mozilla-html:FALSE
version:2.1
end:vcard

_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to