ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Problem to get the final SQL query text from the DaoTemplate
Date Tue, 10 Oct 2006 15:30:28 GMT
There's no public API for retrieving the SQL text.  Part of the issue is
that the text can be variable because of iBATIS' dynamic SQL tags - so the
iBATIS engine potentially re-calculates the text for each query.

In your example - don't you know the table name anyway?  You coded the
statement, so you should know.

If you're trying to do something more general, like a general error handler,
then you could parse the XML file, then parse the SQL.

Jeff Butler
On 10/10/06, Kasatkin Konstantin <KVK@estylesoft.com> wrote:
>
>  Hello guys,
>
> I've been using iBatis about a year and had no problems till now.
> I have an following issue (I'll begin at the root problem):
>
> I use MySQL server as DB engine, it produces messages like "Duplicate
> entry 'SOME VALUE' for key 3"
>
> on unique constraints. The problem is, if I have, for instance, three
> unique indices in one table.
> I perform INSERT query that populates all the fields by record, then I
> catch exception and realise there is no way to know, whick index has
> generated the message. I only see its number.
>
> If I've had the possibility to get the text of the sql statement that has
> jast executed I could extract Table Name from it, return key sequence for
> this table and find out the name of correcponding index.
>
> I've dug the whole source code and couldn't find a way to extract sql
> query text.
>
> Maybe there is some way to get the SQL query text from a DaoTemplate?
>
>

Mime
View raw message