You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Rick Blair <ri...@boeing.com> on 2008/08/11 04:23:33 UTC
MySQL Spatial Data types
Hi all,
Sorry if this is a FAQ, however could not find an answer.
I have an existing mysql (5.1) database that has a column named location
that is a POINT datatype. I used the DataModeler and attached to my
database. I was able to use my existing schema, however the data type in
the Modeler for that column show as OTHER. The class that was generated was
had the following methods:
public void setLocation($classGen.formatJavaType(${attr.Type}) location)
{ writeProperty("location", location); }
public $classGen.formatJavaType(${attr.Type}) getLocation() {
return ($classGen.formatJavaType(${attr.Type}))readProperty("location");
}
Clearly this is just an unmodified template.
I tried changing the data type to BINARY, but got the same result.
Has anyone successfully used spatial data with Cayenne? If so, how?
Thanks in advance.
--
Cheers!
Rick Blair
Re: MySQL Spatial Data types
Posted by Rick Blair <ri...@boeing.com>.
Thanks!
I will give it a try.
--
Cheers!
Rick Blair
> From: Tore Halset <ha...@pvv.ntnu.no>
> Reply-To: <us...@cayenne.apache.org>
> Date: Mon, 11 Aug 2008 07:02:57 +0200
> To: <us...@cayenne.apache.org>
> Subject: Re: MySQL Spatial Data types
>
>
> On 11. aug.. 2008, at 04.54, Aristedes Maniatis wrote:
>
>>
>> On 11/08/2008, at 12:23 PM, Rick Blair wrote:
>>
>>> I have an existing mysql (5.1) database that has a column named
>>> location
>>> that is a POINT datatype. I used the DataModeler and attached to my
>>> database. I was able to use my existing schema, however the data
>>> type in
>>> the Modeler for that column show as OTHER. The class that was
>>> generated was
>>> had the following methods:
>>
>> I haven't used them myself, but you may need to use something like
>> JTS (http://www.vividsolutions.com/JTS) to get these data types
>> across JDBC into Cayenne. And then some customisation of the mysql
>> database adapter [1] might be needed.
>
> Here is an example how to convert between WKT in a database and JTS
> geomertries on the java side. You may have to modify it to let MySQL
> convert the POINT datatype from/to WKT.
>
> http://cwiki.apache.org/CAY/mapping-jts-geometries.html
>
> I am using this in production, but not with MySQL.
>
> Regards,
> - Tore.
>
Re: MySQL Spatial Data types
Posted by Tore Halset <ha...@pvv.ntnu.no>.
On 11. aug.. 2008, at 04.54, Aristedes Maniatis wrote:
>
> On 11/08/2008, at 12:23 PM, Rick Blair wrote:
>
>> I have an existing mysql (5.1) database that has a column named
>> location
>> that is a POINT datatype. I used the DataModeler and attached to my
>> database. I was able to use my existing schema, however the data
>> type in
>> the Modeler for that column show as OTHER. The class that was
>> generated was
>> had the following methods:
>
> I haven't used them myself, but you may need to use something like
> JTS (http://www.vividsolutions.com/JTS) to get these data types
> across JDBC into Cayenne. And then some customisation of the mysql
> database adapter [1] might be needed.
Here is an example how to convert between WKT in a database and JTS
geomertries on the java side. You may have to modify it to let MySQL
convert the POINT datatype from/to WKT.
http://cwiki.apache.org/CAY/mapping-jts-geometries.html
I am using this in production, but not with MySQL.
Regards,
- Tore.
Re: MySQL Spatial Data types
Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 11/08/2008, at 12:23 PM, Rick Blair wrote:
> I have an existing mysql (5.1) database that has a column named
> location
> that is a POINT datatype. I used the DataModeler and attached to my
> database. I was able to use my existing schema, however the data
> type in
> the Modeler for that column show as OTHER. The class that was
> generated was
> had the following methods:
I haven't used them myself, but you may need to use something like JTS
(http://www.vividsolutions.com/JTS) to get these data types across
JDBC into Cayenne. And then some customisation of the mysql database
adapter [1] might be needed.
Ari
[1] http://fisheye6.atlassian.com/browse/cayenne/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql
-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001 fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A