You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by David Broderick <db...@mindshiftinc.com> on 2006/05/05 05:27:50 UTC

Sequence table design issues with iBatis

I am new to iBatis so my apologies if this information is in the 
mailing list or documentation somewhere that I missed (or did not 
understand).

I am using iBatis 2.1.7.597, MySQL 4.1.2, MySql-Connector 3.1.12.

My problem is that I have a GlobalSequence table  (since MySql 4.1.12 
does not support triggers) where I am using auto-increment column to 
generate a global unique ID for all tables in my database.  I am having 
trouble determining the most efficient place to enforce that any insert 
statement is preceded by an insert to the GlobalSequence table that 
returns the ID that was created by the insert.

My preference was to enforce this in the Object SqlMap XML file.  
However I could not find a way to do this.  Multiple SQL statements 
would be one solution, but I see that is not supported, and would not 
be my preferred solution.  I would still like to find a solution where 
I could enforce this in the Object SqlMap xml file.

I have seen the Sequence solution in JPetstore but I think this design 
would be inefficient for my purpose.

For example when I insert a new account into my system it will involve 
an insert to a person table, address table, phone number table, email 
address table etc.  Each insert requires an insert into the 
GlobalSequence table first.  Yes, my requirements are that each row in 
every table will be using a Global Unique ID from the GlobalSequence 
table.

Does anyone have any advice for implementing this using iBatis?

Thanks,

David