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.  [ 7 posts ] 
Author Message
 Post subject: Multiple DB's
PostPosted: Wed Sep 13, 2006 9:37 am 
Beginner
Beginner

Joined: Thu Jul 06, 2006 4:44 am
Posts: 31
Hi.

Is it possible to make one mapping file for multiple db types?
My problem is that i have a application that supports multiple databases
and in the mapping file i need to define the generator either native or sequence. (Oracle, MSSql) Do I need a separate mapping file for each db type or it is possible to set the generation afer loading the asseblies?
Or is there some other way?

Please help!

Thanks
Markov


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 13, 2006 9:55 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Native actually means different things to different databases. For MS SQL, native is the same as identity. For Oracle, native is sequence. You may be able to make use of this fact.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 13, 2006 9:59 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
To add to the previous post: when you set the generator to native with a sequence, the SQL server dialect will just ignore the sequence. This allows to have a single mapping file for multiple databases.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 13, 2006 10:15 am 
Beginner
Beginner

Joined: Thu Jul 06, 2006 4:44 am
Posts: 31
Thanks for the quick answer.

I have tried this:
"NHibernate.Dialect.OracleDialect"
"NHibernate.Connection.DriverConnectionProvider"
"NHibernate.Driver.OracleClientDriver"
for the ado connection with the oracle8i...
Mapping file:
<id name="AttributeId" column="ID_attribute" type="Int32" unsaved-value="0">
<generator class="native">
<param name='sequence'>SQ_attribute</param>
</generator>
</id>

after i have tried to buid the factory i got the following error:
"Dialect does not support identity key generation"

what i can do about this??

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 13, 2006 12:46 pm 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
Are you sure there isn't another class mapped somewhere with <generator class="identity">?
The mapping in your example looks perfectly fine and I use the same construct to support SQL Server (identity), MySQL (identity) and PostgreSQL (sequence).

_________________
Cuyahoga


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 3:02 am 
Beginner
Beginner

Joined: Thu Jul 06, 2006 4:44 am
Posts: 31
it is really strange... i searched twice over all files in the solution and found no identity entries at all.. i'll try to delete all builded dll's and delete all registry entry and try again.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 3:48 am 
Beginner
Beginner

Joined: Thu Jul 06, 2006 4:44 am
Posts: 31
i solved the problem. (it was in the configuration instance)

thank you both for help :)

greetings
markov


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