-->
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.  [ 5 posts ] 
Author Message
 Post subject: Mapping to multiple databases - change the mapping?
PostPosted: Wed Sep 20, 2006 5:26 am 
Newbie

Joined: Tue Nov 22, 2005 1:06 pm
Posts: 4
We have an environment where we use both SQL*Server and Oracle.

Currently I have 1 set of mapping files, for oracle.

The SQL*Server mapping is largely the same, but, I need to change things like

<property name="Data" type="com.mine.hbm.OracleXmlUserType" not-null="false">

to be

<property name="Data" type="string" not-null="false">
<column name="DATA" sql-type="xml"/>
</property>

I can do this by having a parallel set of mapping files. Or I could generate the 2 files from a 'master file' at build time (e.g. ANT property replacement, XSLT, etc). Both feel a bit icky - is there any easier way to do this, perhaps property replacement in the hbm mapping file, conditional includes or something like that?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 5:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
use <typedef> and change the typedef for each deployment.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 5:40 am 
Newbie

Joined: Tue Nov 22, 2005 1:06 pm
Posts: 4
That's ok for items where it's merely the type mapping that changes, but when I looked it didn't help when I actually need to change the underlying column.

For example, in Oracle I have

<id name="Id" type="com.cswgroup.kms.hbm.OracleOIDUserType">
<column name="ID" length="36"/>
</id>

in SQL*Server I need something like (

<id name="Id" type="com.cswgroup.kms.hbm.SQLServerOIDUserType">
<column name="ID" sql-type="uniqueidentifier"/>
</id>

I can't see how to return uniqueidentifier for a usertype, so I have to specify it, and if I don't say (in the former) length=36, then because it's mapped to types.VARCHAR, then the schema generator makes it something huge like VARCHAR(255) which isn't what I want...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 5:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well then some clever search-and-replace is probably the only way.

(or simply don't use the mapping files for schemaexport and just map it without the db specific type mappings ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 5:58 am 
Newbie

Joined: Tue Nov 22, 2005 1:06 pm
Posts: 4
Ok - that's what I thought, it's useful to have it confirmed :-)

What I might actually do then is customise the schema generator, since this is the only part (from what I can see) that is causing me a problem and I can do the rest with a typedef.

Ta.


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