 
     create index email_templ_key on EMAIL_TEMPLATE_ITEM (TEMPLATE_KEY);
 
--- Statement duplicated below in after create table SSQ_Question statement. 
--- Commented out both statements and located a single create hibernate_sequence at the end
--- of this DDL script.
- --   create sequence hibernate_sequence;
+-- SAK-16021 -- The statement 'create sequence hibernate_sequence' is duplicated below following create/alter table SSQ_Question statements.
+-- Multiple statements of this nature will cause the DDL script to fail. 
+-- Instead added generator param to emailtemplateservice EmailTemplate.hbm.xml mapping:
+
+-- <id name="id" type="java.lang.Long" unsaved-value="null">
+-- 	<column name="ID" />
+-- 	<generator class="native">
+-- 		<param name="sequence">emailtemplate_item_seq</param>
+-- 	</generator>
+-- </id>
+
+	create sequence emailtemplate_item_seq;
+ -- create sequence hibernate_sequence;
 
 -- --------------------------------------------------------------------------------------------------------------------------------------
 -- SAK-7924 - add and backfill new site.roleswap permissions into existing realms and templates

        foreign key (SITETYPE_ID) 
        references SSQ_SITETYPE_QUESTIONS;

-- Statement duplicated above after create table EMAIL_TEMPLATE_ITEM statement. 
-- Commented out both statements and located a single create hibernate_sequence at the end
-- of this DDL script.
 --   create sequence hibernate_sequence;

-- --- SAK-15040 site.viewRoster is a newly added permission



CREATE SEQUENCE SAKAI_EVENT_DELAY_SEQ;

-- SAK-16021 -- Create a Hibernate sequence table for all Sakai/hbm implementations
-- create sequence hibernate_sequence;

