NHibernate Forge
The official new home for the NHibernate for .NET community

NHibernate 2.1.0 : Executable queries

[My blog]

I’m proud to announce NH2.1.0 is passing all tests (same of H3.3.1) for bulk actions using HQL.

Some HQL examples:

insert into Animal (description, bodyWeight, mother) select description, bodyWeight, mother from Human

insert into Pickup (id, Vin, Owner) select id, Vin, Owner from Car

insert into Animal (description, bodyWeight) select h.description, h.bodyWeight from Human h where h.mother.mother is not null

update Human h set h.description = 'updated' where exists (select f.id from h.friends f where f.name.last = 'Public' )

update versioned IntegerVersioned set name = :name

update Human set name.first = :correction where id = :id

update Animal a set a.mother = (from Animal where id = 1) where a.id = 2

update Animal set description = :newDesc where description = :desc

update Animal set bodyWeight = bodyWeight + :w1 + :w2

delete SimpleEntityWithAssociation e where size(e.AssociatedEntities ) = 0 and e.Name like '%'

delete Animal where mother is not null

delete from EntityWithCrazyCompositeKey e where e.Id.Id = 1 and e.Id.OtherId = 2

To understand what that mean think about that all executable-queries are working with <subclass>, <joined-subclass>, <subclass> + <join>, <union-subclass>, various POID generators, versioned entities ad son on.

For example using the mapping of this post executing this

insert into Animal (description, bodyWeight) select h.description, h.bodyWeight from Human h where h.mother.mother is not null

the SQL is

insert 
    into
        Animal
        ( description, body_weight ) select
            human0_2_.description as col_0_0_,
            human0_2_.body_weight as col_1_0_ 
        from
            Human human0_ 
        inner join
            Mammal human0_1_ 
                on human0_.mammal=human0_1_.animal 
        inner join
            Animal human0_2_ 
                on human0_.mammal=human0_2_.id,
            Animal animal1_ 
        where
            human0_2_.mother_id=animal1_.id 
            and (
                animal1_.mother_id is not null
            )

… stock… stumb… stumb… stumb… stack… sfrfrfrfrfrfr … (the sound of “goriziana”).


Posted may 13 2009, 02:00 a.m. by Fabio Maulo
Filed under: , , ,

Comments

zoechi wrote re: NHibernate 2.1.0 : Executable queries
on 05-30-2009 10:39

I found that NH 2.1.0 1003 has problems when an entity class is named "Object".

I got an ANTLR exeption. Sorry but I don't have more specific exeption info at hand.

I know Object is a suboptimal name for an Entity, but this was not my decision. After renaming the class it worked fine.

Yesterday's news wrote What's new in NHibernate 2.1
on 07-20-2009 20:44

What's new in NHibernate 2.1

Powered by Community Server (Commercial Edition), by Telligent Systems