Hi,
i need a trigger to be created by hibernate
my database is MySQL 5 and i am trying to avoid running any sql scripts.
i am trying to use this code but the trigger is not being created. Am i missing something?
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.dynwar.user">
<class name="com.dynwar.user.actions.GroupMembersBeans" table="group_members">
<id column="id" name="id">
<generator class="native"/>
</id>
<property name="username" column="username"/>
<property name="group_id" column="group_id" type="integer"/>
</class>
<database-object>
<create>
create trigger group_accounts before insert on group_members
FOR EACH ROW BEGIN
INSERT IGNORE INTO groups (id,group_name,groupDescription) values (1,'ROLE_ADMIN','Admin');
INSERT IGNORE INTO groups (id,group_name,groupDescription) values (2,'ROLE_USER','User');
INSERT IGNORE INTO group_authorities (id,authority,group_id) values (1,'ROLE_ADMIN',1);
INSERT IGNORE INTO group_authorities (id,authority,group_id) values (2,'ROLE_USER',2);
END;
</create>
<drop>
drop trigger group_accounts;
</drop>
<dialect-scope name="org.hibernate.dialect.MySQLDialect"/>
</database-object>
</hibernate-mapping>