Can you suggest a valid mapping for the following scenario. Two tables:
CREATE TABLE "ORDER"
(
"ID" NUMBER(20,0) NOT NULL ENABLE,
"STATUS_ID" NVARCHAR2(10,0)
);
CREATE TABLE "STATUS"
(
"ID" NVARCHAR2(10,0) NOT NULL ENABLE,
"DESCRIPTION" NVARCHAR2(250,0)
);
The respective classes are:
public class Order
{
public virtual Id { get; set; }
public virtual Status { get; set; }
}
public class Status
{
public virtual Id { get; set; }
public virtual Description { get; set; }
}
Status table is static table of value object for the property Proposal.Status and should never be manipulated by code. I want the Order to always be loaded with Status description and code, i.e. Eager Load Proposal.Status.
I’ve read this Ayende’s blog post but there is no exactly the same scenario, albeit I believe it’s quite common.
Edit: note I’m trying to do this as Component Map.
You are trying to map a regular entity with identity as a component (value object). From Ayende’s post:
Component mapping should be used when you are mapping a value type to the same table as the parent entity. You can find more information about NHibernate types in documentation.
Try instead to do it using References mapping, although you might be tempted to use HasOne.