-->
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.  [ 8 posts ] 
Author Message
 Post subject: how to create a custom JoinedSubclassEntityPersister
PostPosted: Tue Dec 12, 2006 7:33 am 
Newbie

Joined: Fri Sep 22, 2006 4:17 am
Posts: 10
Hibernate version: 3.2

Mapping documents:
<class table="TSRFGEOILOT" name="GeometrieIlot"> <!-- polymorphism="implicit" -->
<id column="idIlotGeo" name="idIlotGeo" type="string">
<generator class="assigned"/>
</id>

<one-to-one name="ilotSurface" class="IlotDeclare" constrained="true"/>

<joined-subclass name="GeometrieIlotMetropole" table="TSRFILOTGEOMETROPOLE">
<key column="idIlotGeo"/>
<property column="geometrie" name="geometrie" type="string"/>
<property column="objectid" name="objectid" type="string"/>
</joined-subclass>

<joined-subclass name="GeometrieIlotGuyane" table="TSRFILOTGEOGUYANE" >
<key column="idIlotGeo"/>
<property column="geometrie" name="geometrie" type="string"/>
<property column="objectid" name="objectid" type="string"/>
</joined-subclass>

<joined-subclass name="GeometrieIlotReunion" table="TSRFILOTGEOREUNION" >
<key column="idIlotGeo"/>
<property column="geometrie" name="geometrie" type="string"/>
<property column="objectid" name="objectid" type="string"/>
</joined-subclass>

<joined-subclass name="GeometrieIlotAntilles" table="TSRFILOTGEOANTILLES" >
<key column="idIlotGeo"/>
<property column="geometrie" name="geometrie" type="string"/>
<property column="objectid" name="objectid" type="string"/>
</joined-subclass>
</class>


Name and version of the database you are using:Oracle 10g

Hi,
I would like to create a custom persister for this mapping.
My questions are:
Where do I declare my persister (in my class tag or my subclasses tags)?
How to implement me persister?

thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 8:21 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
The easiest way to implement such a persister is copy-and-paste!
Thats certainly ugly. You have to modify the copied code until
it meets you needs.

If I remember subclassing of a persister wasnt possible.
At least in 3.1.

Configuration can be done in class and subclass tags, e.g.:

Code:
   <class name="baseclass"
      table="mytable" discriminator-value="null"
      persister="basepersister"
      lazy="false">
...
   <joined-subclass name="myclass"
      extends="baseclass"
               persister="mypersister">
...



BTW, why do you need a custom persister ?

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 9:55 am 
Newbie

Joined: Fri Sep 22, 2006 4:17 am
Posts: 10
In fact, I use a GIS with my database.

I store a geometry object in the column "geometrie" but I my code, I retrieve a WKT representing the geometry.
To do that, I made a GeometryPersister with a SigneTableEntityPersister.

Now I have the last mapping and I have to do the same thing so I thought that was the way to do.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 10:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and why is usertypes not enough for you ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 12:44 pm 
Newbie

Joined: Fri Sep 22, 2006 4:17 am
Posts: 10
We tried to do a usertype but we did not success and we did not find anough help.
I found this way because in the SELECT statement my string is generated by a GIS function (ST_ASTEXT) and and in the INSERT or UPDATE statement, the ST_GEOMETRY function is called.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 12:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
David.chau wrote:
We tried to do a usertype but we did not success and we did not find anough help.


did you try jboss support ? :)

Quote:
I found this way because in the SELECT statement my string is generated by a GIS function (ST_ASTEXT) and and in the INSERT or UPDATE statement, the ST_GEOMETRY function is called.


ok - this can be done by using custom sql (e.g. <sql-xxx>)

This is actually a requst I see more and more...what parts did you actually have to change in the persister do it succesfully ? Maybe we should add explicit support for it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 4:30 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi Max,

we have some similar issues, which could only be solved by
modifying the mapping in the already read configuration object.
You can find the complicated details in the jboss support issue:
00009937 bad performance using CLOBs with DB2

Thanks,
Barthel

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 6:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, I remember your case and both usecases are relevant.

Yours is for performance issues where as David.chau is about getting the proper semantics of his GIS data, correct ?

David.chau would there be anything lost for you if just read in the actual value in the db and let a usertype handle the conversion back and forth ? Or is that conversion complex/heavy ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.