-->
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.  [ 1 post ] 
Author Message
 Post subject: defining trigger with database-object
PostPosted: Wed Oct 31, 2007 7:59 am 
Newbie

Joined: Wed Oct 31, 2007 7:41 am
Posts: 3
Hi,

I am having difficulties adding a trigger via the
Code:
<database-object>
tag.

As stated in the hibernate documentation, chapter 5.7 (http://www.hibernate.org/hib_docs/reference/en/html/mapping.html) I try to add a trigger to the database with the following code:

Code:
<hibernate-mapping>
  <database-object>
    <create>
      CREATE OR REPLACE FUNCTION example_function() RETURNS trigger AS $null$
        BEGIN
          -- insert
          IF TG_OP = 'INSERT' THEN
            -- insert_task
          END IF;
          -- delete
          IF TG_OP = 'DELETE' THEN
            -- delete_task
          END IF;
          RETURN NULL;
      END;
      $null$ LANGUAGE plpgsql;
      CREATE TRIGGER example_trigger AFTER INSERT OR DELETE
      ON example_table FOR EACH ROW
      EXECUTE PROCEDURE example_function();
    </create>
    <drop>DROP TRIGGER example_trigger ON example_table;</drop>
    <dialect-scope name="org.hibernate.dialect.PostgreSQLDialect"/>
  </database-object>
</hibernate-mapping>


When adding my trigger manually, everything works out fine. I would like to add the trigger automatically, when deploying my schema via hibernate. When trying to add the trigger via the hibernate shema evolution tool, the trigger is not added.

Thanks for any help on this!

Joerg


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

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.