Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help making Fluent NHibernate create an oracle sequence for each table

I am using Fluent NHibernate's (1.0 RTM) automapping feature to create my oracle database schema. My issue is that all the tables are using a single "hibernate-sequence", whereas I would prefer (and my boss would demand) a sequence generator for each table.

Any ideas?

like image 649
rebelliard Avatar asked Feb 28 '23 00:02

rebelliard


1 Answers

Managed to solve my own solution. Here's the code:

public class OraclePrimaryKeySequenceConvention : IIdConvention
{
    public void Apply(IIdentityInstance instance)
    {
        instance.GeneratedBy.Sequence(string.Format("Sequence_{0}",
                                                    instance.EntityType.Name));
    }
}

Yay. :-)

like image 63
rebelliard Avatar answered Apr 07 '23 12:04

rebelliard