Logo

NHibernate

The object-relational mapper for .NET

NH2.1: Executable HQL

[from my blog]

Mapping:

<class name="SimpleClass" table="TSIMPLE">
<
id type="int">
<
generator class="native" />
</
id>
<
property name="Description"/>
</
class>

Class:

public class SimpleClass
{
public virtual string Description { get; set; }
}

DB fill:

using (var s = OpenSession())
using (var tx = s.BeginTransaction())
{
s.Save(new SimpleClass {Description = "simple1"});
s.Save(new SimpleClass {Description = "simple2"});
tx.Commit();
}

So far doing this:

using (var s = OpenSession())
using (var tx = s.BeginTransaction())
{
s.Delete("from SimpleClass");
tx.Commit();
}

the log is:

OldDeleteLog

But from today (the day of worker), doing this:

using (var s = OpenSession())
using (var tx = s.BeginTransaction())
{
s.CreateQuery("delete from SimpleClass").ExecuteUpdate();
tx.Commit();
}

the log is :NewDeleteLog

 

what it mean is clear, no ?  ;)

Soon some news about bulk insert and update, in HQL.

Now you know one of the reasons because NH2.1.0 release, was postponed.


Posted Tue, 05 May 2009 04:54:00 AM by fabiomaulo
Filed under: query News NHibernate NH2.1 querying HQL

comments powered by Disqus
© NHibernate Community 2016