OK - I will try to explain my question a bit better...
I have classes as following (in my data layer):
Code:
class Picture
{
public int Id = 0;
public Data Data;
}
class Data
{
public Picture Owner;
public int Id = 0;
public byte[] Bytes;
}
I have changed mapping a bit so now it looks like this:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Pix.Data.Picture, Pix.Data" table="OBJECT">
<id name="Id" column="ID" type="Int32" unsaved-value="0"
access="field">
<generator class="foreign">
<param name="property">Data</param>
</generator>
</id>
<one-to-one name="Data" class="Pix.Data.Data, Pix.Data"
constrained="true" access="field" />
</class>
</hibernate-mapping>
and
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Pix.Data.Data, Pix.Data" table="PICTURE">
<id name="Id" column="ID" type="Int32"
unsaved-value="0"access="field">
<generator class="sequence">
<param name="sequence">OBJECT_ID_GEN</param>
</generator>
</id>
<property name="Bytes" column="IMAGE" type="BinaryBlob"
access="field" />
<one-to-one name="Owner" class="Pix.Data.Picture, Pix.Data"
access="field" />
</class>
</hibernate-mapping>
And now I would like to store a picture in my database (Firebird). So I assume I need to follow this:
Code:
void SavePicture(byte[] bytes, ISession sess)
{
ITransaction tr = sess.BeginTransaction();
try
{
Picture pic = new Picture();
pic.Data = new Data();
pic.Data.Bytes = bytes;
sess.Save(pic);
tr.Commit();
}
catch(HibernateException)
{
tr.Rollback();
}
}
And now I wanted to ask my question... but decided to test it before. And finally I discoverred it works this way (did not with previous mapping).
So I also decided not to abandon this post. If it could be helpfull to anyone then I think it is worth to put it anyway. At least I did not find any hints in existing furum archive...