3

I am trying to register new DbTypes for custom user types, and it is only allowing me to use the asp.net DbTypes to associate custom user types that I have created.. for instance:

    /// <summary>
/// An SQL dialect for PostgreSQL 8.2 and above.
/// </summary>
/// <remarks>
/// PostgreSQL 8.2 supports <c>DROP TABLE IF EXISTS tablename</c>
/// and <c>DROP SEQUENCE IF EXISTS sequencename</c> syntax.
/// See <see cref="PostgreSQLDialect" /> for more information.
/// </remarks>
public class PostgreSQL82Dialect : PostgreSQL81Dialect
{
    public PostgreSQL82Dialect()
    {
        RegisterColumnType(DbType.Guid, "uuid");
        RegisterColumnType(DbType.Object, "uuid[]");
        RegisterColumnType(DbType.Object, "integer[]");
        RegisterColumnType(DbType.Binary, "jsonb");
    }

    public override bool SupportsIfExistsBeforeTableName
    {
        get { return true; }
    }

    public override string GetDropSequenceString(string sequenceName)
    {
        return string.Concat("drop sequence if exists ", sequenceName);
    }
}

I added uuid[], integer[] and jsonb. The only problem is when you try to do a schema update it always gets the last column type registered for any given dbtype. The problem with that is, there is no .net data type specified for arrays or blobs... so I have to use object for them. In this case, any custom user type that has a dbtype of object will always be an integer array in the database when I call schema update like so:

   var update = new SchemaUpdate(configuration);
   update.Execute(true, true);

Is there another way to let NHibernate know how to map these columns to the database?

Thanks in advance.

1 Answer 1

2

You need to specify the sql-type in the mapping:

<property name="Foo" type="String">
    <column name="foo" length="64" not-null="true" sql-type="text"/>
</property>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.