[postgis-users] RE: RE: RE: PostGIS - hibernate - EJB3

Norman Barker nbarker at ittvis.com
Mon Oct 9 07:50:43 PDT 2006


Hi Christian,

Thanks for trying out the tutorial and giving me my first bug report!  I
have fixed this error - my apologies although I know JBoss; I don't know
hibernate so well.

I have asked for commit access to postgis this morning but for now if
you replace the the 'replace' method in
org.postgis.hibernate.GeometryType as follows;

	public Object replace(Object original, Object target, Object
owner) throws HibernateException {
		return original;
	}

Then the merge operation will work.

The other bug where you return a list is a result of the location column
being corrupted (it is null) from the use of bug #1, resetting this data
and everything should work - if not let me know.

I welcome more comments on the tutorial and EJB3.  I am currently
figuring out how to server testing with EJB3 - there is talk of being
able to do it with embeddable JBoss - ideas welcomed.

Thanks,

Norman

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
coster
Sent: 06 October 2006 10:53
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] RE: RE: RE: PostGIS - hibernate - EJB3


Hi Norman,
thank you for your tutorial!

Storing data in a geometry column works fine if I create a new object
and
persist it with the entity manager.
But if I try to edit the data with 'merge' from the database manager its
not
working:

PersonEntity pe = entityManager.find(PersonEntity.class, new
Long(1).longValue());
pe.setLocation(new Point(8,5));
entityManager.merge(pe);

How can I fix this problem?

And their is a NullPointerException if I try to read a list of data from
the
database:
	public Object nullSafeGet(ResultSet resultSet, 
		      String[] names, Object owner) throws
HibernateException,
SQLException {
	    Geometry result = null;	
	    String geom = resultSet.getString(names[0]);
	    try{
		    BinaryParser parser = new BinaryParser();
		    result = parser.parse(geom);
	    }
	    catch(NullPointerException e){
	    	logger.error("nullSafeGet() geom result"+geom);
	    }
	    return result;
	}

Tank you for your help,
Christian.


Norman Barker-3 wrote:
> 
> Hi,
> 
> I have been a bit busy, but it is my intention to write a simple
'spatial'
> tutorial on EJB3 using the postgis geometry type, the functionality
will
> be simple but should get you started.  I know I said I would have it
done
> by last w/end so I will put it top on my priority list.
> 
> Apologies for the delay, posting code with no instructions is bad!
> 
> Norman 
> 
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net on behalf of
coster
> Sent: Tue 9/5/2006 6:49 AM
> To: postgis-users at postgis.refractions.net
> Subject: [postgis-users] RE: RE: PostGIS - hibernate - EJB3
>  
> 
> hi, 
> I have the same problem with JBoss and EJB3. 
> The column is type "oid" instead of "geometry".
> 
> I would be very grateful for a solution - here are my postgis-ds.xml
and
> my
> persistence.xml:
> 
> <datasources>
>   <local-tx-datasource>
>     <jndi-name>PostgisDS</jndi-name>
>
<connection-url>jdbc:postgresql://xxx:5432/tourguide</connection-url>
>     <driver-class>org.postgis.DriverWrapper</driver-class>
>     <user-name>xxx</user-name>
>     <password>xxx</password>
>     <new-connection-sql>select 1</new-connection-sql>
>     <check-valid-connection-sql>select 1</check-valid-connection-sql>

>     <metadata>
>        <type-mapping>PostgreSQL 8.1</type-mapping>
>     </metadata>
>   </local-tx-datasource>
> </datasources>
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence">
>     <persistence-unit name="tourguide">
>         <jta-data-source>java:/PostgisDS</jta-data-source>

>         <properties>
>             <property name="hibernate.dialect"
> value="org.hibernate.dialect.PostgreSQLDialect"/>
>             <property name="hibernate.hbm2ddl.auto" value="update"/>
>             <property name="hibernate.show_sql" value="true"/>

>          </properties>        
>     </persistence-unit>
> </persistence>
> 
> Thanks!
> Christian.
> 
> 
> Norman Barker-3 wrote:
>> 
>> 
>> 
>> -----Original Message-----
>> From: postgis-users-bounces at postgis.refractions.net
>> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
>> croisfert
>> Sent: Monday, August 21, 2006 2:54 AM
>> To: postgis-users at postgis.refractions.net
>> Subject: [postgis-users] RE: PostGIS - hibernate - EJB3
>> 
>> 
>> hi,  I am trying to use custom UserType, but it work fine in a pure
>> Hibernate
>> implementation , but not in JBOSS EJB3, the generated geometry column
in
>> postgres is of type "oid" instead of "geometry"    You have any
>> suggestion,
>> i am using jboss-EJB-3.0_RC8-FD and postgis 1.1.3 (on postgres 8.1.4)
>> 
>> 
>> thanks.
>> -- 
>> 
>> 
>> Make sure that the usertype is available on your classpath, I have
only
>> tested it with the Geometry Column type (as the name implies!!), I
also
>> set up postgis as a datasource within JBoss - postgis-ds.xml, and
>> configured the persistence.xml.  I am writing up a doc for this
shortly;
>> just don't have too much time this week.
>> 
>> Norman
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>> 
>> 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/PostGIS---hibernate---EJB3-tf2064211.html#a6146402
> Sent from the PostGIS - User forum at Nabble.com.
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 

-- 
View this message in context:
http://www.nabble.com/PostGIS---hibernate---EJB3-tf2064211.html#a6676142
Sent from the PostGIS - User mailing list archive at Nabble.com.

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list