Hello,
I've got a small problem with a map and cascade.
My Objects + mappings:
Testspecification:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="ETToolV2" namespace="Continental.ETTool">
<class name="Testspecification" table="ET_TESTSPECIFICATION"
lazy="true">
<id name="Id" column="ID_TESTSPECIFICATION" type="Decimal">
<generator class="sequence">
<param name="sequence">ET_TESTSPECIFICATION_SEQ</param>
</generator>
</id>
<map name="VirtualIncarnations" table="ET_VIRTUALTESTSTEPDATA"
lazy="true" cascade="all" >
<key column="ID_TESTSPECIFICATION" />
<index-many-to-many class="Teststep" column="ID_TESTSTEP"/>
<one-to-many class="VirtualTeststepData"/>
</map>
</class>
</hibernate-mapping>
public class Testspecification
{
public virtual Decimal Id { get; set; }
protected virtual IDictionary<Teststep, VirtualTeststepData>
VirtualIncarnations { get; set; }
public Testspecification()
{
VirtualIncarnations = new Dictionary<Teststep,
VirtualTeststepData>();
}
}
VirtualTeststepData + VirtualTeststepDataKey:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="ETToolV2" namespace="Continental.ETTool">
<class name="VirtualTeststepData" table="ET_VIRTUALTESTSTEPDATA"
lazy="true" >
<composite-id class="VirtualTeststepDataKey" name="Key">
<key-many-to-one name="AssignedTestspecification"
column="ID_TESTSPECIFICATION" class="Testspecification" />
<key-many-to-one name="VirtualStep" column="ID_TESTSTEP"
class="Teststep" />
</composite-id>
<property name="Parameter0" type="String" column="PARAMETER0" />
<property name="Parameter1" type="String" column="PARAMETER1" />
<property name="Parameter2" type="String" column="PARAMETER2" />
<property name="Parameter3" type="String" column="PARAMETER3" />
<property name="Confirmed" type="Decimal" column="CONFIRMED" />
<property name="CreationDate" type="DateTime"
column="CREATION_DATE" />
</class>
</hibernate-mapping>
public class VirtualTeststepData
{
public virtual VirtualTeststepDataKey Key { get; set; }
public virtual String Parameter0 { get; set; }
public virtual String Parameter1 { get; set; }
public virtual String Parameter2 { get; set; }
public virtual String Parameter3 { get; set; }
//public virtual Teststep VirtualStep { get; set; }
//public virtual Testspecification AssignedTestspecification
{ get; set; }
public virtual Decimal Confirmed { get; set; }
public virtual DateTime CreationDate { get; set; }
public VirtualTeststepData()
{
this.Confirmed = 0;
CreationDate = DateTime.Now;
Key = new VirtualTeststepDataKey();
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override string ToString()
{
return base.ToString();
}
}
public class VirtualTeststepDataKey: ISerializable
{
public virtual Testspecification AssignedTestspecification { get;
set; }
public virtual Teststep VirtualStep { get; set; }
#region ISerializable Member
public void GetObjectData(SerializationInfo info, StreamingContext
context)
{
throw new NotImplementedException();
}
#endregion
public override bool Equals(object obj)
{
if (obj.GetType() != typeof(VirtualTeststepDataKey))
return false;
VirtualTeststepDataKey compareKey = (VirtualTeststepDataKey)obj;
return (compareKey.AssignedTestspecification.Id ==
this.AssignedTestspecification.Id) && (compareKey.VirtualStep.Id ==
this.VirtualStep.Id);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}
I use it like the following:
public virtual VirtualTeststepData GetVirtualTeststepData(Teststep
teststep, Testspecification testspecification)
{
result = new VirtualTeststepData();
result.Key.AssignedTestspecification = testspecification;
result.Key.VirtualStep = teststep;
this.VirtualIncarnations.Add(teststep, result);
return result;
}
if I do a Session.Save(testspecification) later in my code everything
works fine, but there is no INSERT statement for VirtualTeststepData I
created in the function above. Anybody got an idea how I could solve
this?
Thanks for your help =)
Greetings,
Florian Fanderl
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---