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.  [ 4 posts ] 
Author Message
 Post subject: Using SchemaUpdate hbm2ddl WITHOUT persistence classes
PostPosted: Thu Feb 23, 2006 4:36 am 
Newbie

Joined: Thu Feb 23, 2006 4:01 am
Posts: 3
Location: Bucuresti, Romania
Hello everybody.
Our application is suited to synchronize metadata between a reference database and the production databases installed on clients' locations (having differents dialects, like MS SQL 2000 and Oracle 9i).
I am using NHibernate in our application for its functionnalities of schema export/update (shortly, I take advantage of hbm standard for storing versions of database metadata; I save the reference db as a hbm mapping file, then I execute SchemaUpdate with the new hbm file, on clients' databases).
First of all, of course - SchemaUpdate doesn't exist in NHibernate (I myself adapted to it), but only SchemaExport; however, the 2 features are quite similar so any experience in using SchemaExport, at least, will be very helpful for me.
My BIG issue is that, having the db metadata permanently changing, I cannot rely on any persistence classes (either generated or hand written), because they should adapt each time to the new db structure. There are two questions here:
1. Is there any posibility to NOT use persistence classes for SchemaExport/SchemaUpdate?
2. If not: I already tried this by adapting the code (there is by avoiding the errors generated on trying to load the persistence classes) but I am really stuck in this. I keep having errors in SecondPassCompile(), while NHibernate tries to load some type for a relationship key.

If you can help me, I would really appreciate this.
Cheers,
Deck



P.S. Speaking about SchemaUpdate, I will try later to provide the NHib community with this feature (it will be some overhead to me this, as the code is more or less adapted to my needs, but I'll do it when I will finish the urgent tasks).



Hibernate version:
NHibernate 1.0.2.0

Mapping documents:
....
<class name="testcp-1.0.0.Agence, testcp-1.0.0" table="AGENCE">
<id name="SagenCod" column="SAGEN_COD" type="AnsiString" length="7">
<generator class="assigned" />
</id>
<property name="SagenDes" column="SAGEN_DES" type="AnsiString" length="30" update="false" insert="false" />
<property name="SagenAdr1" column="SAGEN_ADR1" type="AnsiString" length="30" update="false" insert="false" />
<property name="SagenAdr2" column="SAGEN_ADR2" type="AnsiString" length="30" update="false" insert="false" />
<property name="SagenAdr3" column="SAGEN_ADR3" type="AnsiString" length="30" update="false" insert="false" />
....
<!--Associations-->
<!--bi-directional many-to-one association to LOUEUR-->
<many-to-one name="Fk3380641" class="testcp-1.0.0.Loueur" not-null="true">
<column name="SAGEN_LOU" />
</many-to-one>
<!--bi-directional one-to-many association to CONTRATLLD-->
<set name="Contratllds1" lazy="true" inverse="true" cascade="none">
<key>
<column name="SCONLLD_AGEN" />
</key>
<one-to-many class="testcp-1.0.0.Contratlld" />
</set>
</class>
....


Code between sessionFactory.openSession() and session.close():
-

Full stack trace of any exception that occurs:
MappingException: Error running schema update:
Association references unmapped class: testcp-1.0.0.Contratlld.
StackTrace: at NHibernate.Tool.hbm2ddl.SchemaUpdate.Execute(Boolean script, Boolean doUpdate) in d:\\projects\\dotnet\\cpark\\vss_cpark\\majdsk.net\\nhibernate\\tool\\hbm2ddl\\schemaupdate.cs:line 243\r\n at NHibernate.Tool.hbm2ddl.SchemaUpdate.Main(String[] args) in d:\\projects\\dotnet\\cpark\\vss_cpark\\majdsk.net\\nhibernate\\tool\\hbm2ddl\\schemaupdate.cs:line 151


Name and version of the database you are using:
MS SQL 2000

The generated SQL (show_sql=true):
- not reached yet (error is earlier)

_________________
Marius [Deck] Zaharia
Senior Software Developer
AXWAY Romania


Top
 Profile  
 
 Post subject: New details: dynamic models
PostPosted: Thu Feb 23, 2006 6:02 am 
Newbie

Joined: Thu Feb 23, 2006 4:01 am
Posts: 3
Location: Bucuresti, Romania
I found some things on original Hibernate (Java) project: dynamic models (not using persistence classes, but HashMaps or similar). For this, we only need the mapping files. The essential problems are:
1. It seems it is not implemented in NHibernate. Anyone had?... Anyone tried?... Would it cost me much time/effort?
2. Even so, I am not sure SchemaExport/SchemaUpdate works well with it. Again, anyone tried (even on Java)?...

Thanks Again.
Deck

_________________
Marius [Deck] Zaharia
Senior Software Developer
AXWAY Romania


Top
 Profile  
 
 Post subject: Re: Using SchemaUpdate hbm2ddl WITHOUT persistence classes
PostPosted: Thu Apr 12, 2007 7:59 am 
Newbie

Joined: Thu Apr 12, 2007 7:46 am
Posts: 3
Location: Switzerland
zaharia wrote:
P.S. Speaking about SchemaUpdate, I will try later to provide the NHib community with this feature (it will be some overhead to me this, as the code is more or less adapted to my needs, but I'll do it when I will finish the urgent tasks).


I know this post is a bit old but anyway, zaharia are you still alive? Would u have this code yet?

We are starting a new project using NHibernate but we will really need SchemaUpdate. If there is no implementation of this we'll have to create one.

As I've already seen Sergey's msg about having this maybe on v2.0! what exactly is the work left? I've seen a big peace of code about the autoupdate all commented out in the NHib core. Would be only that and the actually class and its Task that is to be done? or much more?

Thank you,
Henrique


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 9:08 am 
Newbie

Joined: Thu Feb 23, 2006 4:01 am
Posts: 3
Location: Bucuresti, Romania
Sorry, I don't work anymore in that project and I changed the company also... I actually used only a part of SchemaUpdate (class structures and hierarchy) but I ended to run out of nH, so it wouldn't be a compatible solution either.
Goodluck then.

_________________
Marius [Deck] Zaharia
Senior Software Developer
AXWAY Romania


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