[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3352) HQL bulk update on JOINED inheritance tree improvement

Donnchadh O Donnabhain (JIRA) noreply at atlassian.com
Wed Jun 17 06:25:33 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33425#action_33425 ] 

Donnchadh O Donnabhain commented on HHH-3352:
---------------------------------------------

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 HHH-3919 ) were causing havoc with MySQL 5.0 statement-based replication.


> HQL bulk update on JOINED inheritance tree improvement
> ------------------------------------------------------
>
>                 Key: HHH-3352
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3352
>             Project: Hibernate Core
>          Issue Type: Improvement
>          Components: query-hql
>    Affects Versions: 3.2.4.sp1
>            Reporter: Anthony Patricio
>            Priority: Minor
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list