I was wondering whether it is possible to make an HQL
insert of composed objects.
I mean, according to the Hibernate Reference, you can execute statements like this:
Code:
"insert into DelinquentAccount (id, name) select
c.id, c.name from Customer c where ..."
But, what if you have a composed object, like the one exposed in the 8th chapter of the same book:
Code:
<class name="eg.Person" table="person">
<id name="Key" column="pid" type="string">
<generator class="uuid"/>
</id>
<property name="birthday" type="date"/>
<component name="Name" class="eg.Name">
<property name="initial"/>
<property name="first"/>
<property name="last"/>
</component>
</class>
?
Would it be possible to do something like this (1):
Code:
insert into Person (Key, birthday, Name.initial, Name.first, Name.last) select c.id, c.birthday, c.initial, c.firstname, c.lastname from Customer c where ...
?
I am currently working in a project where initial bulk loads of objects will be necessary. I have thought of this feature because it would be very convenient for such scenarios.
Thanks in advance.
(1) Since I am a born optimist, I have tried a similar HQL statement just to see if that worked. Not surprisingly, it did not.