Page 1 of 1

Using NHibernate with VARRAY

Posted: Wed 26 Oct 2016 10:27
by stefan.werner
Hello,

I'm trying to use OraceArray / VArray with NHibernate.Fluent mapping.
Based on the http://blog.devart.com/nhibernate_and_oracle.html tutorial I was able to establish the connection to the db and use it with my existing mapping. Only a few mappings e.g.VArray where not working.

How to set my mapping class for NHibernat in order to work this out?
Currently my mapping for the VArray column looks like:

Code: Select all

Map(x => x.PropertyName).Column("COLUMN_NAME")
                .CustomType<SomeTypeRepresentingTheList>()
                .CustomSqlType("VARRAY_TYPE_IN_ORACLE");
The VArray itself is defined by:

Code: Select all

create or replace TYPE "VARRAY_TYPE_IN_ORACLE" AS VARRAY(10) OF NUMBER(9);
By the way, I'm using the latest Version of dotConnect for Oracle: 9.1.131 (20-Oct-2016)


With best regards,
Stefan

Re: Using NHibernate with VARRAY

Posted: Fri 28 Oct 2016 13:26
by Pinturiccio
VARRAY is not a simple datatype, like NUMBER or VARCHAR. It is a user defined type (UDT), and ORMs don’t support UDT. Unfortunately, the support of UDT in ORM's is beyond the scope of our support and we cannot provide more information.

Re: Using NHibernate with VARRAY

Posted: Fri 28 Oct 2016 15:06
by stefan.werner
Thanks for the reply, although it's not quite correct. Even NHibernate with the built in oracle driver does support UDT / VARRAY. You only have to implement the UDT type from oracle .net driver.

Anyway, have a nice weekend.