You didn't say this, but I assume you are relying on NHibernate to generate the DDL for your domain dynamically. (else you could just generate the DDL and change it manually before you ship your software) If you want NHibernate to consider field lengths while generating DDL, I think you can do this by using the NHibernate Validator. The blog post here shows an example of the before/after DDL that is generated:
http://ayende.com/Blog/archive/2009/05/01/nhibernate-validator.aspx See the documentation here: http://nhforge.org/wikis/validator/nhibernate-validator-1-0-0-documentation.aspx Not sure what version of NHibernate you're using, but I'd be interested to know if this works with NHibernate 3.0; I haven't tried it yet. (I may be facing this problem eventually as well.) Regards, Mike On Wed, Oct 13, 2010 at 9:16 AM, fedehf <[email protected]> wrote: > Hello. I've been having serious trouble with Nhibernate 2.1.0.4000 + > Fluent 1.0 + Oracle 10g. > Scenario: > There are legacy tables on another schema and the requirement is to > reference them on my domain. > There was no problem configuring the mappings. We managed to do so by > using custom sql types for Identity fields. > That seems to work ok but the problem arrives when trying to reference > (create FK) between my tables and theirs. > > I give you an axample: > > Legacy Table > > FOO > (PK) codFoo: varchar2(4) -> Not the default that nhibernate uses. > > Entity of my domain > > FOOBAR > (PK) Id : number(20) > (FK) Foo : nvarchar(255) -> This is what nhibernates creates. > > > The problem is that as they are different types, oracle doesn't > support creating the FK. > > Is there any workaround for this? If I upgrade to a greater version > will this be solved? > > Mapping: > > public class FooMap: classmap<Foo> > { > public FooMap() > { > table("Foo"); > id(x => x.codFoo, "codFoo").CustomSqltype("varchar2(4)"); > } > } > > public class FooBarMap: classmap<FooBarMap> > { > public FooBarMap() > { > table("FooBar"); > id(x => x.Id); > References(x=>x.Foo); <- Can't specify type here. > } > } > > NOTE: The legacy schema is untochable and due to this thread > http://groups.google.com/group/nhusers/browse_thread/thread/7aa36dc69e60bfe1 > I can't upgrade to 2.1.2.4000. > > > Thanks in advance for your support. > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
