These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: extension of the criteria api
PostPosted: Wed Dec 07, 2005 9:29 am 
Newbie

Joined: Wed Dec 07, 2005 9:03 am
Posts: 2
Hibernate version: 2.1.7
Hi,
we are using in a spatial data application the criteria api to encapsulate complex spatial queries. in our database the geometries appear as object columns. these are transformed in jjava objects by using user types. the problem now is to transform objects from one spatial reference system in to another. because sometimes another spatial reference system is needed as it is in the database. the function we are using is the Oracle Spatial function
Code:
sdo_cs.transform

At the moment we are using HQL-queries or createSQLQuery as the following one:
Code:
Query q = this.getSession().createSQLQuery(
                "SELECT " +
                "{this}.ID as ID0_, " +
                "{this}.NAME as NAME0_, " +
                "{this}.DESCRIPTION as DESCRIPT3_0_, " +
                "{this}.X_SPACING as X_SPACING0_, " +
                "{this}.Y_SPACING as Y_SPACING0_, " +
                "{this}.X_COUNT as X_COUNT0_, " +
                "{this}.Y_COUNT as Y_COUNT0_, " +
                "sdo_cs.transform({this}.LL_POINT, " + sc.getSrs().getSrid() + ") as LL_POINT0_, " +
                "sdo_cs.transform({this}.MBB, " + sc.getSrs().getSrid() + ")  as MBB0_, " +
                "{this}.Z_ORDINATES as Z_ORDIN10_0_ " +
                      "from Grid {this} WHERE " + se.toSqlString(null, null, null, null) + " ", "this", Grid.class);

As you can see some columns are transformed. how is it possible to extent Hibernate that if one attribut or column class identifies one special typ automatically a function is added?

thanks for help,
elnacho


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 09, 2005 9:11 am 
Newbie

Joined: Wed Sep 22, 2004 10:10 am
Posts: 15
Location: Darmstadt, Germany
In Hibernate 3, this issue can be addressed by implementing the Projection Interface (here, I assume you named your Implementation is called CSTransformProjection) and the adding the Projection to the criteria:
Code:
List results = session.createCriteria(SpatialObject.class)
    .setProjection( new CSTransformProjection("column", targetCS) )
    .list();

Probably, you can also use the class SQLProjection; I just didn't find any documentation on it in the standard APIdoc.

Best Regards,

beelzebot
--


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.