This version of the manual is outdated. For the latest version, follow this link: http://www.jooq.org/doc/3.0/manual.
| The jOOQ User Manual. Multiple Pages : jOOQ classes and their usage : Serializability of jOOQ objects | previous : next |
# Attaching QueryParts
The only transient element in any jOOQ object is the The Factory class's underlying java.sql.Connection. When you want to execute queries after de-serialisation, or when you want to store/refresh/delete Updatable Records, you will have to "import" or "re-attach" them to a Factory
// Deserialise a SELECT statement ObjectInputStream in = new ObjectInputStream(...); Select<?> select = (Select<?>) in.readObject(); // This will throw a DetachedException: select.execute(); // In order to execute the above select, attach it first Factory create = new Factory(connection, SQLDialect.ORACLE); create.attach(select);
# Automatically attaching QueryParts
Note, this functionality is deprecated with jOOQ 2.1.0. Please use the ExecuteListener API instead, to provide jOOQ queries with a java.sql.Connection before execution.
In simple cases, you can register a ConfigurationProvider in jOOQ's ConfigurationRegistry
// Create your own custom ConfigurationProvider that will make // your default Factory available to jOOQ ConfigurationProvider provider = new CustomConfigurationProvider(); // Statically register the provider to jOOQ's ConfigurationRegistry ConfigurationRegistry.setProvider(provider);
Once you have executed these steps, all subsequent deserialisations will try to access a Configuration (containing a JDBC Connection) from your ConfigurationProvider. This may be useful when
- transporting jOOQ QueryParts or Records via TCP/IP, RMI, etc (e.g. between client and server), before immediately executing queries, storing UpdatableRecords
- Using automatic mechanisms as known in Wicket
| The jOOQ User Manual. Multiple Pages : jOOQ classes and their usage : Serializability of jOOQ objects | previous : next |
