-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate trigger
PostPosted: Mon May 23, 2011 10:05 pm 
Newbie

Joined: Sun Nov 01, 2009 9:24 pm
Posts: 12
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>




Top
 Profile  
 
 Post subject: Re: Hibernate trigger
PostPosted: Thu Nov 24, 2011 2:11 am 
Newbie

Joined: Thu Nov 24, 2011 2:01 am
Posts: 2
Hi gmorcos,
did you find solution for this? If so what was the problem.
Please let me know about it.

Also as even i am working on triggers now , it would be of great help if you could explain the statements between BEGIN and END.
Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.