The situation is as follows: I own a table called "Entidade" in the database, and a table "Medico". The table "Medico" is a joined-subclass entity in the table as below:
<joined-subclass name="Medico" table="Medico">
<key column="SEQ_ENTIDADE"/>
<property name="DSC_CRM"/>
<property name="DSC_ESPECIALIDADE"/>
<property name="FLG_SEXO"/>
</joined-subclass>
The user should be able to use an "Entidade" already registered to "Turn it" on a "Medico". When I try to save the object "Medico" that extends the class "Entidade" with the same ID "Entidade" has saved the following error occurs:
violation of PRIMARY or UNIQUE KEY constraint "PK_ENTIDADE" on table "ENTIDADE"
My class "Medico":
public class Medico : Entidade
{
public virtual string DSC_CRM { get; set; }
public virtual string DSC_ESPECIALIDADE { get; set; }
public virtual Sexo FLG_SEXO { get; set; }
}
There is the possibility of making this "Transformation"?
Should you need anything else to understand the situation just ask.
I think a subclass should not be used in your case. That is not a question of nHibernate but to classes and inheritance.
If you have additional properties for your instance that can be added or removed over time I would not use inheritance for your model but aggregation. And then your joined subclass problem will become a reference problem (or HasMany) and you are fine.
Regards, Michael