HQL bulk update on JOINED inheritance tree improvement

Description

Updating of entities in an inheritance hierarchy with the JOINED strategy.
Trying to update all entities of this hierarchy using a hql statement that affects attributes/columns
of the base entity only doesn't need the insert into TEMP / Update BASE_TABLE / delete TEMP logic

Update BASE_TABLE is sufficient and more efficient.

Environment

None

Activity

Show:
Donnchadh Ó Donnabháin
May 20, 2009, 4:20 PM

similarly for joined tables (e.g. <join table="my_table"><property ... />...</join> that aren't part of the inheritance hierarchy) where the fields in the joined aren't being updated.

Donnchadh Ó Donnabháin
June 17, 2009, 12:25 PM

Interestingly, in my case moving the join to my subclasses eliminated the temporary table.
i.e. I changed the following:

<hibernate-mapping package="com.company.project.domainmodel.articles">
<class name="AbstractArticle" table="ARTICLES">
<id name="id">
<generator class="native" />
</id>
<discriminator column="article_type" />
...
<join table="ARTICLE_BODY" optional="true">
<key column="article_id" not-null="true" />
<property name="body" />
</join>

<subclass name="PublishedArticle" discriminator-value="PUBLISHED">
...
</subclass>

<subclass name="UnpublishedArticle" discriminator-value="UNPUBLISHED">
...
</subclass>
</class>
</hibernate-mapping>

to:

<hibernate-mapping package="com.company.project.domainmodel.articles">
<class name="AbstractArticle" table="ARTICLES">
<id name="id">
<generator class="native" />
</id>
<discriminator column="article_type" />
...

<subclass name="PublishedArticle" discriminator-value="PUBLISHED">
...
<join table="ARTICLE_BODY" optional="true">
<key column="article_id" not-null="true" />
<property name="body" />
</join>
</subclass>

<subclass name="UnpublishedArticle" discriminator-value="UNPUBLISHED">
...
<join table="ARTICLE_BODY" optional="true">
<key column="article_id" not-null="true" />
<property name="body" />
</join>
</subclass>
</class>
</hibernate-mapping>

and changing the update statement to refer to the base class rather than the subclass (as it happens it was reasonable to do this in our case).

The temporary tables (especially with ) were causing havoc with MySQL 5.0 statement-based replication.

Assignee

Unassigned

Reporter

Anthony Patricio

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure