Archive for the ‘Fluent Nhibernate’ Category
The environment :
Working with Oracle 10g.
At the mapping files of the FNH on the ID column define the sequence to work with.
This is a relevant sequence used by the relevant trigger used for the current table.
The db is a legacy db – using triggers to increment the records on the insert.
The problem :
When I save the record I’m getting back the record number. Well I’m getting the expected number +1 , every time . The record is being inserted and the record number jumps two times instead of one.
In the trigger you must enter check to see if the new value is null , and only then increment the trigger . If it’s not null it means it was incremented by FNH already and there is no need to activate the increment in the trigger.
CREATE OR REPLACE TRIGGER DOAR_DEV.CUSTOMER_TRG1
ON DOAR_DEV.CUSTOMER REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
NEW.CST_RECID IS NULL
tmpVar := 0;
SELECT Customer_SEQ.NEXTVAL INTO tmpVar FROM dual;
:NEW.Cst_RecID := tmpVar;
WHEN OTHERS THEN
— Consider logging the error and then re-raise
For a long time tried to find the solution for HasMany relationship not through ID property of the entity .
Starting from Fluent NHibernate build 164 there is a way , no patches included –
HasMany(x => x.Collection_TChild).AsBag()
Crazy thing , after including the FNH.dll of 164 version , we were compelled to add
column property to the Mapping . So , it means that we went through all our mappings
Map(x => x.Property).Column(“PropertyNameAsItAppearsInOracleDataBase”);
otherwise the NHibernate didn’t recognized the mappings…