-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Add a "pass-through" clause to all generated SQL?
PostPosted: Sun Aug 03, 2008 6:25 pm 
Newbie

Joined: Sun Aug 03, 2008 6:07 pm
Posts: 2
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


Top
 Profile  
 
 Post subject: Issue resolved
PostPosted: Tue Aug 05, 2008 6:13 am 
Newbie

Joined: Sun Aug 03, 2008 6:07 pm
Posts: 2
>Next, we tried modifying the SQL in an Interceptor onPrepareStatement().
>This works fine, but does not cover INSERTs, DELETEs or UPDATEs.

Apologies. That statement was wrong. onPrepareStatement() should cover our requirements.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.