Hi all
I could be missing something simple, but the mapping files below do
not give the expected results - or results as I would have expected
them to be more accurate. I could be attempting something that is not
possible
Basically the data structure is as follows
Files -> many FileLifecycles -> each lifecycle can have a FileStatus
(legacy db explains the composite keys).
I had thought that by setting insert="false" update="false" on the
many-to-one collection of File Status (FkFilesFileStatus) in the
FileLifecycle mapping file that these objects would be ignored when
writing to the database. However, in the application, I need in some
cases to create 'dummy' FileStatus objects on Filelifecycles objects.
When saving I then get an error re transient objects should be saved
first. How is this if these objects are meant to be ignored. I had
planned on using the FileStatusCode to set and update the FileStatus
on each FileLifeCycle.
As i said i could be missing something simple or am attempting
something thats not meant to be.
Any pointers would be greatly appreciated.
many thanks
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Metadata.FileLifecycle,Metadata"
table="`FILE_LIFECYCLE`" lazy="true"
optimistic-lock="version" dynamic-update="true" dynamic-
insert="true">
<composite-id name="Id" class="Metadata.FileLifecycleId,Metadata">
<key-property name="FileId" column="`FILE_ID`" type="int"/>
<key-property name="Cycleorder" column="`CYCLEORDER`" type="int" /
>
</composite-id>
<version name="Version" column="LASTUPDATED" type="Timestamp"></
version>
<property type="string" name="FileStatusCode"
column="`FILE_STATUS_CODE`"/>
<many-to-one name="FileStatus" cascade="none" not-found="ignore"
insert="false" update="false">
<column name="FILE_STATUS_CODE"/>
</many-to-one>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Metadata.FileStatus,Metadata" table="`FILE_STATUS`"
lazy="true"
optimistic-lock="version" dynamic-update="true">
<id name="FileStatusCode" column="`FILE_STATUS_CODE`"
type="string">
<generator class="assigned" />
</id>
<version name="Version" column="LASTUPDATED" type="Timestamp"></
version>
<bag name="FkFilesFileStatus" inverse="true" lazy="true"
cascade="none">
<key column="`FILE_STATUS_CODE`" />
<one-to-many class="Metadata.Files,Metadata" />
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Metadata.Files,Metadata" table="`FILES`" lazy="true"
optimistic-lock="version" dynamic-update="true" dynamic-
insert="true">
<id name="FileId" column="`FILE_ID`" type="int">
<generator class="assigned" />
</id>
<version name="Version" column="LASTUPDATED" type="Timestamp"></
version>
<bag name="Lifecycles" lazy="true" cascade="all-delete-orphan"
inverse="true">
<key column="`FILE_ID`" not-null="true"/>
<one-to-many class="Metadata.FileLifecycle,Metadata" />
</bag>
</class>
</hibernate-mapping>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.