We're using Hibernate 3.1.3 to access a Connx (
www.connx.com) database.
For reasons I won't go into, we need to add a Connx-specific clause to every generated SQL statement - INSERTs, DELETEs and UPDATEs as well as queries.
The clause is in the format:
{ fn setfilename <table-name>, '<physical-file-name>' }
for example:
{ fn setfilename customer, '/data/branch/ST/STcustomer' }
(The curly brackets are required.)
Essentially, we need this clause (which has to be dynamically generated for each SQL statement) to be passed through to the database. We've tried registering it as a function in a custom Dialect, but the parser doesn't like it. Not surprising, as it's not a function, and doesn't result in a column being returned from the database.
Next, we tried modifying the SQL in an Interceptor onPrepareStatement(). This works fine, but does not cover INSERTs, DELETEs or UPDATEs.
Is there any simple way to cover these cases? Even if we have to use a customised Hibernate? We tried modifying the Insert, Delete and Update classes, but it looks they generate and cache some SQL at configuration time, and our clause needs to be dynamically generated for every SQL statement.
I'm wondering if there is a point (or small number of points) in Batcher and its subclasses where we can hook in our code close to the point where the SQL gets executed.
There is the Hibernate native SQL facility, of course.... but not much point using Hibernate if we have to code all our SQL manually.
Any help or ideas welcome