[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] eclipseLink + PostGIS datatypes
|
The translation is rather good. Since I don't explicitly use get- or
setObject() I don't know at which part of the persist process I should check
this. Could you give me a hint?
The error actually indicates that this type (point) cannot be converted
automatically so it should be done via setObject().
This oracle support by eclipselink is interesting but at the moment I
hopeful to get postgres work ;-) What do you mean with: "Oracle returns
spatial data a Struct datatypes"? Postgres can be extended by Postgis which
contains several spatial datatypes such as Point a.s.o. These are concrete
Java-Objects...
Thanks Philipp
James Sutherland wrote:
>
> My German is not so good, Google translate gives,
>
> "The SQL for an instance of org.postgis.Point to use data type can not be
> derived. Use 'setObject ()' set an explicit type for him."
>
> for your error, could you translate this better?
>
> What does JDBC return when selecting the Point type using getObject()? and
> how does it require it to be set? The error seems to indicate we are
> using setObject(), but it does not like this?
>
> EclipseLink has support for spatial datatypes on Oracle, using its
> JGeometry converter. Oracle returns spatial data a Struct datatypes, is
> PostgreSQL similar?
>
>
>
> Philipp123451 wrote:
>>
>> Hello everybody.
>> As the topic indicates, I'm trying to use JPA
>> (eclipselink-2.0.0.v20091127-r5931) with glassfish v3 and PostGres 8.4
>> with PostGIS 1.4.1. The Problem is, PostGIS datatypes (e.g.
>> org.postgis.Point) is converted to type "bytea" during the persistence
>> process. I've found several blogs saying this should be possible, but for
>> me this seems impossible. For example:
>> http://www.naxos-software.de/blog/index.php?/archives/40-PostgreSQLs-geometrische-Datentypen-und-die-Java-Persistence-API.html
>> . At the bottom of this article someone says, this:
>> @Entity @Table(name = "route_point") public class RoutePoint implements
>> Serializable { @Id @GeneratedValue @Column(name = "id", nullable = false)
>> private Integer id;
>>
>> @Column(name = "seq_no", nullable = false)
>> private int seqNo;
>> @JoinColumn(name = "route", referencedColumName = "id")
>> @ManyToOne
>> private Route route;
>> @Column(name = "geo_point", nullable = false)
>> @Lob
>> @Convert
>> private Geometry pointAsObject;
>>
>> public RoutePoint() {
>> }
>>
>> }
>>
>> shall be working. I tried but was not successfull. eclipselink returns:
>>
>> Exception [EclipseLink-4002] (Eclipse Persistence Services -
>> 2.0.0.v20091127-r5931):
>> org.eclipse.persistence.exceptions.DatabaseException
>> Internal Exception: org.postgresql.util.PSQLException: FEHLER: Spalte
>> »test« hat Typ point, aber der Ausdruck hat Typ bytea
>> Error Code: 0
>> Call: INSERT INTO test (id, test) VALUES (?, ?)
>> bind => [601, [B@552da4]
>> Query: InsertObjectQuery(entity.Test[id=601])
>>
>> Another way I tried is to implement the "Converter" interface of
>> eclipseLink. I added to the attribute of type point the following:
>>
>> @Converter(name="convert", converterClass=MyTypeConverter.class)
>> public class Test implements Serializable {
>> private static final long serialVersionUID = 1L;
>>
>> @Column(name = "test")
>> @Convert("convert")
>> private Point test;
>>
>> @Id
>> @Basic(optional = false)
>> @Column(name = "id")
>> @GeneratedValue(strategy=GenerationType.AUTO)
>> private Integer id;
>> ...
>> }
>>
>> The implementation of the Converter looks like that:
>>
>> public class MyTypeConverter implements Converter{
>> public Point convertObjectValueToDataValue(Object objectValue,
>> Session session) {
>> return (Point) objectValue;
>> }
>>
>> public Point convertDataValueToObjectValue(Object dataValue, Session
>> session) {
>> return (Point)dataValue;
>> }
>>
>> public boolean isMutable() {
>> return false;
>> }
>>
>> public void initialize(DatabaseMapping mapping, Session session) {
>> //throw new UnsupportedOperationException("Not supported yet.");
>> }
>> }
>>
>> eclipseLink now returns:
>>
>> Exception [EclipseLink-4002] (Eclipse Persistence Services -
>> 2.0.0.v20091127-r5931):
>> org.eclipse.persistence.exceptions.DatabaseException
>> Internal Exception: org.postgresql.util.PSQLException: Der in SQL für
>> eine Instanz von org.postgis.Point zu verwendende Datentyp kann nicht
>> abgeleitet werden. Benutzen Sie 'setObject()' mit einem expliziten Typ,
>> um ihn festzulegen.
>> Error Code: 0
>> Call: INSERT INTO test (id, test) VALUES (?, ?)
>> bind => [601, POINT(0 0)]
>> Query: InsertObjectQuery(entity.Test[id=601])
>>
>> I don't see the failure. I would be very pleased if someone could tell me
>> how to solve this problem.
>>
>> With regards
>> Philipp
>>
>
>
--
View this message in context: http://old.nabble.com/eclipseLink-%2B-PostGIS-datatypes-tp27026862p27026886.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.