Carlos
Carlos

Reputation: 13

Fluent NHibernate Composite Mapping <long, string>

I am having problems with mapping a particular table that has as primary key. Let's say I have this table:

CREATE TABLE ALERT_EMAIL
(
    IDALERT NUMBER(10, 0) NOT NULL,
    EMAIL   VARCHAR2(100 BYTE) NOT NULL,
    CONSTRAINT ALERT_EMAIL_PK PRIMARY KEY ( IDALERT , EMAIL ) ENABLE
)

Here is my mapping:

public class AlertEmailMap : ClassMap<AlertEmail>
    {
        public AlertEmailMap()
        {
            Schema("XXX");
            Table("ALERT_EMAIL");
            CompositeId().KeyReference(x => x.Alert, "IDALERT").KeyReference(x => x.Email, "EMAIL");
        }
    }

I am getting this error: "An association from the table ALERT_EMAIL refers to an unmapped class: System.String"

Is it because I have a string in my CompositeId? How can I map that table correctly?

Thanks.

Upvotes: 1

Views: 239

Answers (1)

Firo
Firo

Reputation: 30803

the email is no refernce to another class. Map it as simple property

CompositeId()
    .KeyReference(x => x.Alert, "IDALERT")
    .KeyProperty(x => x.Email, "EMAIL");

Upvotes: 2

Related Questions