The error "could not retrieve version" and the inner error "column unknown" thorws when I try to replicate a C2 object:
C2 c2obj previously instantiated in another database.
Session.Replicate(c2obj,ReplicationMode.Overrite);
My classes:
Code:
class C1
{
int _id;
public int Id
{
get { return _id; }
set { _id=value; }
}
private string _prop1;
public string Prop1
{
get { return this._prop1; }
set { this._prop1=value; }
}
}
class C2 : C1
{
private string _prop2;
public string Prop2
{
get { return this._prop2; }
set { this._prop2=value; }
}
}
Hibernate version:1.0.4 Mapping documents:Mapping of class C1:
Code:
<?xml version='1.0' encoding='utf-8' ?>
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.0' default-access='field' >
<class name='C1' table='TBL_C1'>
<id name='_id' column='id_c1' type='Int32' unsaved-value='0'>
<generator class='native'>
<param name='sequence'>seq_id_c1</param>
</generator>
</id>
<property name='_prop1' column='prop1' type='String' length='40' />
</class>
</hibernate-mapping>
Mapping of class C2:
Code:
<?xml version='1.0' encoding='utf-8' ?>
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.0' default-access='field' >
<joined-subclass name='C2' extends='C1' table='TBL_C2' >
<key column='id_c2' />
<property name='_prop2 column='prop2' type='String' length='35' />
</joined-subclass>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
NHibernate.SQL: SELECT id_c2 FROM TBL_C1 WHERE id_c2 = @p0
NHibernate.SQL: @p0 = '1'
the NHibernate generates the sql using the table from the parent class C1 and it should be from the real class C2.
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html