Hi, while trying to run this code I get the ADOException (InnerException):
There is already an open DataReader associated with this Connection which must be closed first.
What can it be? Thanks.
Hibernate version:
1.02
Mapping documents:
Code:
public class Query
{
public Query()
{
}
public Query(string text)
{
this.text = text;
}
private long id;
private string text;
public string Text
{
get { return text; }
set { text = value; }
}
private long Id
{
get { return id; }
set { id = value; }
}
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="MyAssembly" namespace="MyNamespace">
<class name="Query">
<id name="Id" unsaved-value="0">
<generator class="native"/>
</id>
<property name="Text" unique="true" length="255"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
using (ISession session = Database.OpenSession()) // Session Factory
{
ITransaction tr = session.BeginTransaction();
IEnumerator en = session.Enumerable(
"select count(*) from Query query where query.Text = ?",
"text",
NHibernateUtil.String).GetEnumerator();
en.MoveNext();
if ((int)en.Current == 0)
{
session.Save(new Query("text"));
}
tr.Commit();
}
Full stack trace of any exception that occurs:
at NHibernate.Transaction.AdoTransaction.Commit()
[Skipped]
Name and version of the database you are using:
MySQL Server 5.0 and MySQL Connector Net 1.0.7.
The generated SQL (show_sql=true):
select count(*) as x0_0_ from Query query0_ where (query0_.Text=?p0)
?p0 = 'text'