This is an already known bug. To work around it, I put an instruction in my build-torque.xml file in order to replace lines in the sqldb.map generated file:
<target
name="insert-sql">
<!-- The following task is a work around to avoid a bug from -->
<!-- torque: it may create tables and attempt to record them in the -->
<!-- ID_TABLE before the ID_TABLE is created -->
<replace file="${torque.out.dir}/sql/sqldb.map"
token="id-table-schema.sql=default"
value="id-table-schema.sql=${database.name}" />
<torque-sql-exec
driver="${databaseDriver}"
.......
As I do not use maven, I dont know if you can use this work around as is.
Hope this helped
Frederic
Owens, Ryan wrote:
After running:
maven torque:main
maven torque:create-db
and
maven torque:id-table-init-sql
I run:
maven torque:insert-sql
The output is listed below but it appears that the ID_TABLE is being inserted into prior to its creation.
Is this a known bug or am I messing something up?
The output below shows 3 attempts to insert into ID_TABLE, and then it runs:
id-table-schema.sql
which looks like this:
--------------
# -----------------------------------------------------------------------
# ID_TABLE
# -----------------------------------------------------------------------
drop table if exists ID_TABLE;
CREATE TABLE ID_TABLE
(
ID_TABLE_ID INTEGER NOT NULL,
TABLE_NAME VARCHAR (255) NOT NULL,
NEXT_ID INTEGER,
QUANTITY INTEGER,
PRIMARY KEY(ID_TABLE_ID),
UNIQUE (TABLE_NAME)
);
--------------
When the process completes I have an Empty ID_TABLE in the db.
So if these got switched somewhere.. how do I switch them back?
Thanks,
Ryan Owens
=======================
OUTPUT
------
C:\test\projects\maven-torque-test>maven torque:insert-sql
__ __
| \/ |__ Jakarta _ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.0-beta-6
C:\test\projects\maven-torque-test
torque:insert-sql:
[torque-sql-exec] Our new url -> jdbc:mysql://127.0.0.1/torquetest
[torque-sql-exec] Executing file: C:\test\projects\maven-torque-test\src\sql
\project-schema.sql
[torque-sql-exec] Executing file: C:\test\projects\maven-torque-test\src\sql
\project-schema-idtable-init.sql
[torque-sql-exec] [ERROR] Failed to execute: insert into ID_TABLE (id_table_
id, table_name, next_id, quantity) VALUES (101, 'book', 1000, 10)
[torque-sql-exec] [ERROR] java.sql.SQLException: General error: Table 'torqu
etest.id_table' doesn't exist
[torque-sql-exec] [ERROR] Failed to execute: insert into ID_TABLE (id_table_
id, table_name, next_id, quantity) VALUES (102, 'publisher', 1000, 10)
[torque-sql-exec] [ERROR] java.sql.SQLException: General error: Table 'torqu
etest.id_table' doesn't exist
[torque-sql-exec] [ERROR] Failed to execute: insert into ID_TABLE (id_table_
id, table_name, next_id, quantity) VALUES (103, 'author', 1000, 10)
[torque-sql-exec] [ERROR] java.sql.SQLException: General error: Table 'torqu
etest.id_table' doesn't exist
[torque-sql-exec] 6 of 9 SQL statements executed successfully
[torque-sql-exec] Our new url -> jdbc:mysql://127.0.0.1/torquetest
[torque-sql-exec] Executing file: C:\test\projects\maven-torque-test\src\sql
\id-table-schema.sql
[torque-sql-exec] 8 of 11 SQL statements executed successfully
BUILD SUCCESSFUL
Total time: 9 seconds
--
To unsubscribe, e-mail: <mailto:turbine-torque-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-torque-user-help@;jakarta.apache.org>
-- To unsubscribe, e-mail: <mailto:turbine-torque-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:turbine-torque-user-help@;jakarta.apache.org>
