[postgis-users] RESEND- Help with using Hibernate with PostGIS
Sandeep Kumar Jakkaraju
sandeepkumar.jakkaraju at gmail.com
Sat Nov 18 05:34:41 PST 2006
Hi Norman
Please Help ..
This my class definition ...
public class RoadNetwork {
private Geometry location=null;
private long id;
public long getId()
{
return id;
}
public void setId(long id)
{
this.id = id;
}
public void setLocation(Geometry loc)
{
this.location = loc;
}
public Geometry getLocation()
{
return location;
}
}
My RoadNetwork.hbm.xml....
<?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="hello.RoadNetwork"
table="Roads"
>
<id
name="id"
column="id"
type="java.lang.Long "
>
<generator class="increment">
</generator>
</id>
<property
name="location"
type=" org.postgis.hibernate.GeometryType"
update="true"
insert="true"
column="location"
/>
</class>
</hibernate-mapping>
main method ..inserting in database...
{
SessionFactory sessions = new
Configuration().configure().buildSessionFactory();
session =sessions.openSession();
session.connection().setAutoCommit(true);
System.out.println("Inserting Record");
LineString geom = new LineString(lng_str);
RoadNetwork net = new RoadNetwork();
net.setLocation(geom);
session.save(net);
session.flush();
session.close();
System.out.println("Done");
}
Errors : I get
[java] Hibernate: insert into Roads (location, id) values (?, ?)
[java] 19:01:40,215 WARN JDBCExceptionReporter:71 - SQL Error: 0,
SQLState : null
[java] 19:01:40,216 ERROR JDBCExceptionReporter:72 - Batch entry 0
insert i nto Roads (location, id) values (<stream of 105 bytes>, 1) was
aborted. Call ge tNextException to see the cause.
[java] 19:01:40,217 WARN JDBCExceptionReporter:71 - SQL Error: 0,
SQLState : 42804
[java] 19:01:40,217 ERROR JDBCExceptionReporter:72 - ERROR: column
"locatio n" is of type oid but expression is of type bytea
[java] 19:01:40,224 ERROR AbstractFlushingEventListener:300 - Could not
syn chronize database state with session
[java] org.hibernate.exception.SQLGrammarException: Could not execute
JDBC batch update
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20061118/2c3796d0/attachment.html>
More information about the postgis-users
mailing list