cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emerson CastaƱeda <eme...@gmail.com>
Subject Re: MySQL Spatial Extensions
Date Sat, 11 Aug 2012 11:07:11 GMT
I had a similar case with posgis-postgressql and what I have used as
datatype was the Object class directly.

Also you can do something like this, using types "OTHER" and "BLOB" for
db-entity and obj-entity respectively:

<db-entity name="table1">

<db-attribute name="field1" type="INTEGER" length="4"/>

<db-attribute name="field2" type="VARCHAR" length="254"/>

<db-attribute name="fieldGEOMETRY" type="OTHER" length="1"/>

....

....

<obj-entity name="table1" className="org.xyz.domain.Table1"
dbEntityName="table1">

<obj-attribute name="field1" type="java.lang.Integer"
db-attribute-path="FIELD1"/>

<obj-attribute name="field2" type="java.lang.String"
db-attribute-path="FIELD2"/>

<obj-attribute name="geometry" type="java.lang.Blob"
db-attribute-path="FIELDGEOMETRY"/>


It works to me, I hope it can be useful to you too with Mysql extention.

By the way, other problematic situation was the using of the special GIS
functions, in my case it was solved by using wrapper stored procedures in
order to call those functions, see next a sample of mapping:

<procedure name="ProcedureName">

<procedure-parameter name="PARAM1" type="VARCHAR" direction="in"/>

<procedure-parameter name="PARAM2" type="INTEGER" direction="in"/>

<procedure-parameter name="PARAM3" type="DECIMAL" length="22"
direction="out"/>

<procedure-parameter name="PARAM4" type="DECIMAL" length="22"
direction="out"/>

</procedure>


and It can be called using the next java code:


ProcedureQuery query = new ProcedureQuery("ProcedureName", SPResult.class);

// Set "IN" parameter values

query.addParameter("PARAM1", rc);

// run query as a normal select query

List objects = this.getDataContext().performQuery(query);

// process results

Iterator it = objects.iterator();

Object obj[] = new Object[4];

while (it.hasNext()) {

SPResult res = (SPResult) it.next();

obj[0] = res.getParam2();

obj[1] = res.getParam3();

obj[2] = res.getParam4();

}


Emerson
On Aug 11, 2012 11:00 AM, "Seamus Minogue" <sminogue@yahoo.com> wrote:

> I am trying to map the POINT data type from mysql's spatial extensions (
> http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions.html) but when
> I have the modeller reverse engineer the DB it doesn't assign a java type
> for the field.
>
> I have done some searches and havent really found much about this. I found
> one email message in the archives addressing this but it was a little
> sparse on details.
>
> Anyone able to point me to an answer on how to do this mapping? Or maybe
> just the Java type I should put in (it would be nice if it was that simple).

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message