if (newRow != null && newRow.next()) {
                final Result<Record> result = create.fetch(newRow);
                EventBusUtil.getInstance().post(new 
ModelPostSavedEvent(result.into(Account.class)));
            } else {
                final Result<Record> result = create.fetch(oldRow);
                EventBusUtil.getInstance().post(new 
ModelPostRemovedEvent(result.into(Account.class)));
            }Hi Lukas,

I've came to the point adding these triggers now. Well, the H2 API offers 
me 2 possibilities - I extended the TriggerAdapter.
    public void fire(final Connection conn, final ResultSet oldRow, final 
ResultSet newRow) throws SQLException {
}

There's no information about the statement type - but we can get it by 
checking oldRow and newRow against null.
My idea was now to fetch this resultSet and trigger the event with the 
resulting pojo.

So first of all - this is requried to get the executor:

    final Settings settings = new Settings();
    settings.setExecuteLogging(false);
    final Executor create = new Executor(conn, SQLDialect.H2, settings);

I have to disable default logging due to my posted issue request to use 
jooq without writing my own listener.
Then this code is used to to fetch the row - please note - this code might 
contain some mistakes inside the if condition:

            if (newRow != null && newRow.next()) {
                final Result<Record> result = create.fetch(newRow);
                EventBusUtil.getInstance().post(new 
ModelPostSavedEvent(result.into(Account.class)));
            } else {
                final Result<Record> result = create.fetch(oldRow);
                EventBusUtil.getInstance().post(new 
ModelPostRemovedEvent(result.into(Account.class)));
            }

Once executing this trigger, I get a huge memory leak (it will "consume" 
all my memory if not stopped) and a huge cpu usage (up to 100%). I tested 
the code further and came to the result - this leaks occur once calling:
                
final Result<Record> result = create.fetch(oldRow);

At least - that's the preferred way outlined at 
http://www.jooq.org/doc/2.6/manual/getting-started/use-cases/jooq-as-a-sql-executor/

After seeing this - I thought about a deadlock situation that prevents h2 
to finish the intial (for example) INSERT statement - this then prevents my 
trigger from fetching the actual resultset. But this can't be true. First 
of all there's the API allowing me to use this resultSet, secondly that 
wouldn't explain that huge memory and cpu usages.

Can you explain what's going on?

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to