Need help with this one. In hibernate.cfg.xml my connection_string property doesn't specify initial catalog (defafult DB), 'cause I need to be able to access different DBs on that server.
When I create Configuration object and add default_schema property (for example: "XXX.dbo") , I get folowing SQL generated:
if exists (select * from dbo.sysobjects where id = object_id(N'XXX.dbo.Entity') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table XXX.dbo.Entity
create table XXX.dbo.Entity (...)
Do you see the problem here? "(select * from dbo.sysobjects..." There is no database specified here and the script looks for Entity table in DEFAULT (i.e. master -- since I don't specify initial db in connection string prop either) database, tries to drop it and then creates table in XXX database! If you run the script twice you'll get an error "There is already an object named 'Entity' in the database."
I think the setting default_schema property to "XXX.dbo" should generate the script to this:
... select * from XXX.dbo.sysobjects...
Hibernate version:
NHibernate-2.0.0.GA
Regards
Maciej Szymanski
|