[hibernate-issues] [Hibernate-JIRA] Commented: (EJB-335) Polymorphic delete fails while creating a temp table

Steve Ebersole (JIRA) noreply at atlassian.com
Tue Feb 12 10:22:32 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/EJB-335?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29507 ] 

Steve Ebersole commented on EJB-335:
------------------------------------

If that is really the case, then how in the world do the actual selects (using that same union) work?

> Polymorphic delete fails while creating a temp table
> ----------------------------------------------------
>
>                 Key: EJB-335
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-335
>             Project: Hibernate Entity Manager
>          Issue Type: Bug
>    Affects Versions: 3.2.1
>         Environment: Postgres 8.3, hibernate hibernate 3.2 from rev 14201
>            Reporter: Heiko W. Rupp
>
> We have an Entity
> @Entity
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> MeasurementData {
>     @EmbeddedId
>     MeasurementDataPK id;
>     @JoinColumn(name = "SCHEDULE_ID", insertable = false, updatable = false)
>     @ManyToOne(fetch = FetchType.LAZY)
>     Schedule schedule;
>  ..
> }
> and Subclasses:
> MeasurementDataNum(_1h,_6h,..) extends MeasurementData {
>     Double value;
> }
> MeasurementDataTrait extends MeasurementData {
>    String value;
> }
> A bulk delete  "DELETE FROM MeasurementData md WHERE  md.schedule IN (:schedules ) "
> fails with 
> Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk delete
>         at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
>         at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:57)
> Postgres 8.3 complains about the following SQL:
> ERROR:  UNION types double precision and character varying cannot be matched
> insert into HT_MeasurementData 
>     select measuremen0_.TIME_STAMP as TIME_STAMP, measuremen0_.SCHEDULE_ID as SCHEDULE_ID 
>     from ( 
>        select value, maxvalue, SCHEDULE_ID, TIME_STAMP, minvalue, 1 as clazz_
>           from MEASUREMENT_DATA_NUM_1D 
>        union all 
>        select value, maxvalue, SCHEDULE_ID, TIME_STAMP, minvalue, 
> 2 as clazz_ 
>          from MEASUREMENT_DATA_NUM_1H 
>        union all 
>        select value, maxvalue, SCHEDULE_ID, TIME_STAMP,
>  minvalue, 3 as clazz_ 
>          from MEASUREMENT_DATA_NUM_6H 
>        union all 
>        select value, null::float8 as maxvalue, SCHEDULE_ID, TIME_STAMP, null::float8 as minvalue, 4 as clazz_ 
>           from RHQ_MEASUREMENT_DATA_TRAIT 
>       ) measuremen0_ 
>     where SCHEDULE_ID in ($1 , $2 , $3)
> So basically it creates a column for "value" and tries to insert strings and doubles into it.
> The "obvious" :-) solution would be only to insert the timestamp and schedule id into the table and not the value and other stuff that is not needed to identify the items to delete.

-- 
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