Note: I use Hibernate3 and MySql5.1 InnoDb.
I can run sql statement on command line successfully, but once I put these sql statements in Hibernate Mapping file, always gave me this error message.
Why cannot I use temporary table?
Caused by: org.hibernate.exception.GenericJDBCException: could not execute query ... 55 more Caused by: java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
the following is my sql statement: CREATE TEMPORARY TABLE access_group_change_list select distinct modification_timestamp, modified_by from LOYALTY.access_group_history where client_id = :clientId and ( db_action in ('I', 'D') or modification_timestamp in (select max(modification_timestamp) from LOYALTY.access_group_history where client_id = :clientId) ) ;
CREATE TEMPORARY TABLE access_group_list select access_group_id from LOYALTY.access_group where client_id = :clientId ;
CREATE TEMPORARY TABLE access_group_object_change_list select modification_timestamp, modified_by from LOYALTY.v_organisation_object_group_history where top_id = :clientId order by modification_timestamp desc limit 1 ;
create temporary table agi_1 select access_group_id from access_group_list; create temporary table agi_2 select access_group_id from access_group_list; create temporary table agi_3 select access_group_id from access_group_list;
CREATE TEMPORARY TABLE other_latest_change_list select modification_timestamp, modified_by from access_group_object_change_list union select distinct modification_timestamp, modified_by from LOYALTY.access_group_client_rhistory where modification_timestamp in ( select max(modification_timestamp) from LOYALTY.access_group_client_rhistory where access_group_id in (select access_group_id from agi_1) ) union select distinct modification_timestamp, modified_by from LOYALTY.access_group_members_rhistory where modification_timestamp in ( select max(modification_timestamp) from LOYALTY.access_group_members_rhistory where access_group_id in (select access_group_id from agi_2) ) union select distinct modification_timestamp, modified_by from LOYALTY.access_group_visibility_rhistory where modification_timestamp in ( select max(modification_timestamp) from LOYALTY.access_group_visibility_rhistory where viewer_access_group_id in (select access_group_id from agi_3) ) ;
CREATE TEMPORARY TABLE all_change_list (select distinct modification_timestamp, modified_by from other_latest_change_list order by modification_timestamp limit 1) union (select modification_timestamp, modified_by from access_group_change_list) ;
select distinct modification_timestamp, modified_by from all_change_list order by modification_timestamp desc
|