SchemaUpdate won't work for me because if that entity needs to be
deleted then I still have to use SchemaExport that will drop the
sequence.

The best solution for me is to create my own sequence generator by
inheriting from NHibernate.Id.SequenceGenerator and override its
SqlDropString method to return an empty array.  That would have been
perfect.  However, the problem is that even though this is an
implementation of the method from IPersistentIdentifierGenerator, it
is not declared as "virtual".  So when I derive my own generator and
use it, SequenceGenerator.SqlDropString.  It would have been nice if
that method was declared as virtual so that I vould override it.  I
would hate to modify nhibernate's source and then have to maintain its
build in my environment.

Is there anything in C# that would allow me to accomplish the
overriding of a non-virtual method.

I tried this and it did not work.

public new string[] SqlDropString(NHibernate.Dialect.Dialect dialect)
{
     return new string[0];
}

This still calls the base class's method.

Any help is appreciated.


On Aug 4, 9:56 pm, Diego Mijelshon <[email protected]> wrote:
> Have you tried with SchemaUpdate instead of SchemaExport?
> (I have absolutely no idea if it works)
>
>     Diego
>
>
>
> On Wed, Aug 4, 2010 at 20:56, Waqar Sadiq <[email protected]> wrote:
> > Hi,
>
> > I am using NHibernate 2.1.2 and the underlying database is Oracle.  I
> > am running into a problem but before explaining the problem, I want to
> > explain some functionality in my application.
>
> > This application allows the user to cerate a data model.  For each
> > entity that they create in the data model, I generate a C# class, a
> > mapping file and the corresponding table in the database.  Later if
> > they add a new entity to the data model, its corresponding class,
> > mapping files are generated and the assembly is rebuilt.  All the C#
> > classes and mapping files are complied into an assembly and this
> > assembly is later used to initialize a hibernate session.  Always, the
> > table is created by creating a Configuration object that has the
> > mapping for the table that needs to be created and then SchemaExporter
> > is used.  The following code cerates the table.
>
> > //////////////////// begin code //////////////////////////
> > Configuration cfg = new Configuration();
> > IDictionary<string, string> properties = new Dictionary<string,
> > string>();
> > properties.Add("dialect", dinfo.dialect);
> > properties.Add("connection.provider",
> > "NHibernate.Connection.DriverConnectionProvider");
> > properties.Add("connection.driver_class", dinfo.driver);
> > properties.Add("connection.connection_string", db_connectionString);
> > cfg.AddProperties(properties);
> > cfg.AddResource("mapping name", "assembly name");
>
> > SchemaExport se = new SchemaExport(cfg);
> > se.SetDelimiter (";");
> > se.Execute(true, true, false);
> > //////////////////////////////////////////////////////////////
>
> > That all works but a specific problem has surfaced.
>
> > The generated mappings use the "sequence" generator for id
> > generation.  For some desired behavior, all entities share the same
> > sequence for id.  So when a new table is created, hibernate
> > essentially resets the underlying sequence.
>
> > Is there anyway to tell hibernate not to reset the sequence if it
> > already exists?
>
> > Thanks for your help.
>
> > Waqar
>
> > --
> > 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]<nhusers%[email protected]­>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
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.

Reply via email to