Question
How to map dictionary collection cross database with the same .hbm configuration ?
Scenario
I am trying to map a dictionary property:
Dictionary<string, string> Phrases { set; get; }
with the following .hbm configuration:
<map
name="Phrases"
cascade="save-update"
table="ATTRIBUTE_LOCALE"
lazy="true">
<key column="RESOURCE_ID" /> <!-- foreign key -->
<index column="LOCALE_NAME" type="string" />
<element column="PHRASE" type="string" />
</map>
and the following is the table create SQL of [ATTRIBUTE_LOCALE] for MS SQL:
CREATE TABLE ATTRIBUTE_LOCALE (
CUID int IDENTITY(1, 1) NOT NULL,
RESOURCE_ID int NOT NULL,
FIELD_NAME nvarchar(255) DEFAULT 'VALUE' NOT NULL,
LOCALE_NAME nvarchar(255) NOT NULL,
PHRASE ntext NULL
);
but if I change my database from MS SQL Server to Oracle and Oracle database cannot use IDENTITY(1, 1) to generate the primary key automatically. In Oracle, I will have some trouble due to insert table with NULL Primary Key.
How can I solve this problem?