Ok I figure this out!
By looking at the source code it was all clear and obvious:
I didn't set autoIncrement property of the column element to true!
After I correct it it works fine!

Never trust documentation only source code!

Sergey

Sergey Moiseyev wrote:

Hello

It looks that I have slightly different problem.

1) When I use toruqe-3.0 and defaultIdmethod="native" it generates correct sql script with auto_incrment modifier for pkey column and insertion works fine.
But this only if the pkey column has the type INTEGER. If I change it to BIGINT, Torque generates sql without auto_increment modifier.
For some reason it doesn't like this column type!
Does anyone know why? Or how can I make it work?


2) I tried to use toruqe-gen.3.1 - it doesn't work event with INTEGER type.
This version generates errors in the log file in relation to the om/MapBuilder.vm


Fri Oct 24 18:13:46 EST 2003 [error] ResourceManager : unable to find resource 'VM_global_library.vm' in any resource loader.
Fri Oct 24 18:13:46 EST 2003 [info] Velocimacro : error using VM library template VM_global_library.vm : org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'VM_global_library.vm'
..
Fri Oct 24 18:13:48 EST 2003 [error] Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode)
Fri Oct 24 18:13:48 EST 2003 [error] Left side ($dbprops.get("idMethod")) of '==' operation has null value. If a reference, it may not be in the context. Operation not possible. om/MapBuilder.vm [line 112, column 103]
Fri Oct 24 18:13:48 EST 2003 [error] Left side ($dbprops.get("idMethod")) of '==' operation has null value. If a reference, it may not be in the context. Operation not possible. om/MapBuilder.vm [line 114, column 68]
..
Fri Oct 24 18:13:49 EST 2003 [info] ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader
Fri Oct 24 18:13:49 EST 2003 [error] RHS of #set statement is null. Context will not be modified. om/Object.vm [line 268, column 1]
Fri Oct 24 18:13:49 EST 2003 [error] RHS of #set statement is null. Context will not be modified. om/Object.vm [line 268, column 1]
Fri Oct 24 18:13:49 EST 2003 [error] RHS of #set statement is null. Context will not be modified. om/Object.vm [line 1411, column 1]


----
I don't know much about velocity scripts, so not sure how to fix it?
Here are the lines from the files:

extract from om/MapBuilder.vm:
line 28: #if ($generateDeprecated == "true")
line 112: #elseif ($table.IdMethod == "sequence" || ($table.IdMethod == "native" && $dbprops.get("idMethod") == "sequence"))
line 114: #elseif ($table.IdMethod == "native" && $dbprops.get("idMethod") == "identity")


extract from om/Object.vm:
line 268:    #set ($coldefval = $column.DefaultValue)
line 1411:  #set ($coldefval = $col.DefaultValue)

Thank you very much!


Tom Talbott wrote:


Try setting the idMethod="native" for the table instead of defaultIdMethod
for the database. That is what I use and I don't need an ID_TABLE.


----- Original Message -----
From: "Sergey Moiseyev" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 22, 2003 7:10 PM
Subject: Using native id method for MySQL




Hello

I have problem inserting data in to the tables when using database
attribute

defautIdMethod = "native".

I am using torque-3.0.
I have no probs when using idbroker. When I change it to native, rebuild
and run the pogram I get the following exception:


org.apache.torque.TorqueException: IdGenerator for table 'frm_category'
is null
   at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:690)
   at


com.peoplelogic.db.BaseFrmCategoryPeer.doInsert(BaseFrmCategoryPeer.java:216


)


at


com.peoplelogic.db.BaseFrmCategoryPeer.doInsert(BaseFrmCategoryPeer.java:565


)


at com.peoplelogic.db.BaseFrmCategory.save(BaseFrmCategory.java:508)
at com.peoplelogic.db.BaseFrmCategory.save(BaseFrmCategory.java:470)
at com.peoplelogic.db.BaseFrmCategory.save(BaseFrmCategory.java:450)
at
com.peoplelogic.test.TorqueTest.createFormCategories(TorqueTest.java:59)


at com.peoplelogic.test.TorqueTest.main(TorqueTest.java:43)

All the tables created OK with autoincrement primary keys
This is my property file:

log4j.category.org.apache.torque = ALL, org.apache.torque
log4j.appender.org.apache.torque = org.apache.log4j.FileAppender
log4j.appender.org.apache.torque.file =
${torque.applicationRoot}/logs/torque.log
log4j.appender.org.apache.torque.layout = org.apache.log4j.PatternLayout
log4j.appender.org.apache.torque.layout.conversionPattern = %d [%t] %-5p
%c - %m%n
log4j.appender.org.apache.torque.append = false


torque.database.default = sergey
torque.database.sergey.adapter = mysql
torque.database.sergey.driver = org.gjt.mm.mysql.Driver
torque.database.sergey.url = jdbc:mysql://192.168.1.3/sergey
torque.database.sergey.username = systems
torque.database.sergey.password =  tunafish

Note, thate I have set

torque.database.sergey.adapter=mysql

but I can't find corresponding adapter in the adapter package! Could it
be the problem?

Could anyone help me to understand whats going on? And what is the
advantages of using native instad of idbroker. And if I use native do I
still need the ID_TABLE?

Thanks,

Sergey


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to