Hello,
After getting the
NHibernate build up and running and doing some testing, it's clear that the
"lastval()" approach to retrieving the ID value of a new row will work _most_ of
the time. Unfortunately, it doesn't if you have a trigger function that also
updates another table. lastval() returns the value of the last updated sequence,
not the original table's sequence.
We've been burned by
this and are frantically searching for a solution. I tried replacing lastval()
with currval(pg_get_serial_sequence('[table]', '[column]')), but this only works
for tables, not for views. So again, an incomplete solution that doesn't work
for us. Since I'm far from being a PostgreSQL expert, I'm hoping there's a more
elegant and complete solution out there.
Our other option is
to stop using the trigger, but that will obviously cause some significant
changes to our code base to accomodate, I am hoping there is a way to avoid it.
Regardless, I think the lastval() usage in the dialect is a booby trap awaiting
the next person who stumbles upon it and it should be
changed.
Thanks,
Richard