sergey wrote:
Pilotbob wrote:
I'm pretty sure NHibernate doesn't look at the unique and not-null attributes. Those are only for the hbm2dll schema creation.
You will probably have to query to see if the DOC-ID exists yet prior to creating a new object.
[Then again, I could be wrong.]
You are right. NHibernate doesn't check uniqueness, since this would require an additional query in general. I think that H2.1 does check uniqueness among the objects known to the session, but I am really not sure about this either. In general, it's the job of the database to check these constraints.
Thanks Guys. Pilotbob and sergey.
What I've done was to go ahead and get my hands dirty: simple as it might be, the overwelling number of parameters and miscellaneous stuffs to consider with NHibernate had me stuck at how to formulate the uniqueness constraint on MS SQL for that particular column.
So, I got the SchemaExport class up and running in my project and let it re-create the schema based on what I had understood the attributes helped to configure it to do. Now it's got clearer, from the demarcation between what NHibernate does and what it counts on the DBMS to do, to NHibernate's responsibility for object persistence being within the context of a session..
Actually, I spent a lot of time trying to get the picture of what the praiseworthy documentation for Hibernate was trying to say, but from inheritance mapping using discriminator, joined-subclass, composite-id, outer-join="true", property-ref,
"isn't the collection on the 'one' end of the one-to-many relationship so why do they say it's the 'many' end?" ... it all just flew way over my head before I dozed off... and then, there was NHibernate's unit tests and examples. Light. I guess I know what to do on Hibernate's side as well :)
Thank You Guys.
Rico.