You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Sergey Moiseyev <se...@peoplelogic.com.au> on 2003/10/24 13:01:52 UTC

Re: Using native id method for MySQL with BIGINT column type

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" <se...@peoplelogic.com.au>
>To: <to...@db.apache.org>
>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: torque-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: torque-user-help@db.apache.org
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: torque-user-help@db.apache.org
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>For additional commands, e-mail: torque-user-help@db.apache.org
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Casting types width jdbc2xml

Posted by Amine Bousta <ab...@lxsolutions.com>.
Hello

I'm using torque 3.1 and Mysql
I have a SQL file and I want to generate om classes.
I didn't succeed in using sql2xml so I imported my sql file in my db and I'm
trying now to use jdbc2xml to generate the xml schema.

First issue :
Columns of type "DateTime" are converted into a "Timestamp" type in the xml
schema.
Is there a way to keep the type unchanged for Datetime columns?


Secondly :
When I have an "Integer" column, it converts me to "Integer" in the xml
file.
But when I generate om classes, java fields are "int" instead of
"java.lang.Integer". It's a problem for me when I want to set a null value.
Is there a way to either :
1. During the jdbc->xml conversion, force torque to write "type=Integer
javaType=java.lang.Integer" instead of "type=Integer" only
OR
2. During the xml->om conversion, force torque to write "Integer" by default
instead of "int" for Integer column types.

Thank you

Amine




---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


SQL 2 XML

Posted by Amine Bousta <ab...@lxsolutions.com>.
Hello,

I'm using Torque 3.1 and MySQL.
I have a sql file containing "create table"s.
When I run ant with sql2xml, the Java process never ends.
It says "Parsing SQL..." but then it doesn't progress anymore.

Did it happen to anybody else?

Regards
Amine



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Using native id method for MySQL with BIGINT column type

Posted by Sergey Moiseyev <se...@peoplelogic.com.au>.
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" <se...@peoplelogic.com.au>
>> To: <to...@db.apache.org>
>> 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: torque-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: torque-user-help@db.apache.org
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: torque-user-help@db.apache.org
>>>
>>>   
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>>
>>  
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org