comparison artifact-database/src/main/java/de/intevation/artifactdatabase/h2/CollectionAccessUpdateTrigger.java @ 229:328ef982d768

When an artifact is touched the collections which contain the artifact are touched, too. artifacts/trunk@1631 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 31 Mar 2011 08:58:42 +0000
parents
children 16cd059945e5
comparison
equal deleted inserted replaced
228:dd977fb7552e 229:328ef982d768
1 package de.intevation.artifactdatabase.h2;
2
3 import org.h2.api.Trigger;
4
5 import java.sql.Connection;
6 import java.sql.SQLException;
7 import java.sql.PreparedStatement;
8
9 import de.intevation.artifactdatabase.SQL;
10
11 import org.apache.log4j.Logger;
12
13 public class CollectionAccessUpdateTrigger
14 implements Trigger
15 {
16 private static Logger logger =
17 Logger.getLogger(CollectionAccessUpdateTrigger.class);
18
19 public static final String COLLECTIONS_TOUCH_TRIGGER_FUNCTION =
20 SQL.get("collections.touch.trigger.function");
21
22 public void init(
23 Connection conn,
24 String schemaName,
25 String triggerName,
26 String tableName,
27 boolean before,
28 int type
29 )
30 throws SQLException {
31 logger.debug("CollectionAccessUpdateTrigger.init");
32 }
33
34 public void fire(
35 Connection conn,
36 Object [] oldRow,
37 Object [] newRow
38 )
39 throws SQLException {
40 logger.debug("CollectionAccessUpdateTrigger.fire");
41 PreparedStatement stmnt = conn.prepareStatement(
42 COLLECTIONS_TOUCH_TRIGGER_FUNCTION);
43 stmnt.setObject(1, newRow[0]);
44 stmnt.execute();
45 stmnt.close();
46 }
47
48 public void close() throws SQLException {
49 logger.debug("CollectionAccessUpdateTrigger.close");
50 }
51
52 public void remove() throws SQLException {
53 logger.debug("CollectionAccessUpdateTrigger.remove");
54 }
55 }
56 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org