Hi all, I made a database model which uses UUIDs as primary keys. The database has the possibility to synchronize with other databases so UUIDs are a good choice. To synchronize I need to track all deletions into a deletion table and to update timestamps like created and lastModified for every interesting table. To do this I wrote triggers.
The database is moving from SQLite3 to H2. SQLite3 does support SQL- Triggers which make many things easier. The SQLite version was working well. The problem is that I cannot access BINARY or UUID field inside a trigger but I can access other fields. I get results like '[B@34d507e9' which seem to be an address or so. I read http://www.h2database.com/html/datatypes.html#uuid_type but I cannot access the returned object as a java.util.UUID object. For example: public void fire(Connection conn, Object[] oldRow, Object[] newRow) throws SQLException { UUID uuid; String sql; if (oldRow != null) { uuid = (UUID)oldRow[0]; sql = "UPDATE " + this.tableName + " SET lastModified='" + timestampFormat.format(new Date()) + "' WHERE id='" + uuid.toString() + "';"; System.out.println(this.tableName + "." + this.triggerName + ".fire():"); System.out.println("uuid as String: " + uuid.toString()); System.out.println(sql); this.stmt.executeUpdate(sql); } } produces: UPDATE TABLE SET lastModified='2011-12-19 15:46:57.171' WHERE id=x'[B@34d507e9'; I tried primary keys as BINARY(32) and tried extending the TriggerAdapter class with no luck. Who can help? Thanks in advance. Regards Frederik -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
