This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi again, I hope you can help me with a problem with saving test code_
I have a parent table Attribute with a primary key AttributeId using a sequence as the identity generator, and a child table AttributeValue with a primary key AttributeId that is a foreign key mapping to Attribute. The problem is that i don't now how to set the identity generator on the AttributeId column for table AttributeValue. It needs to get its value from the Attribute table. I have tried to use an Interceptor to set AttributeId to the value from Attribute.AttributeId but that only generates this exception on the commit: "identifier of an instance of TestModel.AttributeValue was altered from 0 to 264059" I have attached an image of the model and the SQL code to create the tables. Is there a way to get the child table to get the id from the parent table ? Thanks, Daniel The programs and versions i have: NHibernate Designer Version: 2.0.255.19857 Visual Studio 2010 with SP1 Database: PostgreSQL 9.1 Windows 7 Enterprise 64-bit Update: Hi, I have found a example of my problem being fixed by using generator class='foreign'. Se here: http://stackoverflow.com/questions/2799044/nhibernate-one-to-one-mapping-issue-with-child-object-insert-error And by changing the generated mapping for the id in my AttrbuteValue class to:
It works but if i rebuild the change is lost, is there a way to set this in NHibernate Designer ? Thanks! |
|
|
We don't currently support As an interim workaround, you can modify the generated mapping by implementing the CustomizeMappingDocument partial method. This allows you to post-process the XML at runtime, before the configuration system reads it. See http://www.mindscapehq.com/help/nhdesigner/Help%20Topics/CustomisingGeneration.html for info about how to do this. But hopefully we'll be able to get you an update shortly so this won't be necessary! |
|
|
Hi Daniel, The next nightly build (available from about 1200 GMT) will include a Foreign option for Identity Generator. Let us know if you run into any problems with it! |
|