db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henning P. Schmiedehausen" <...@intermeta.de>
Subject Re: IdGenerator is null
Date Tue, 13 Jul 2004 16:04:18 GMT
ron piterman <ron.piterman@gmx.net> writes:

>I am doing fine without this table :-p
>It is not needed when one uses native id generator.
>Cheers,
>ron

Hi,

yes, but it depends on the database. If you have a database where
NATIVE maps to IDBROKER, it will not work.

	Regards
		Henning


>Henning P. Schmiedehausen wrote:

>>ron piterman <ron.piterman@gmx.net> writes:
>>
>>  
>>
>>>Well, I added the table, but I still get the exception :(
>>>    
>>>
>>
>>  
>>
>>>org.apache.torque.TorqueException: IdGenerator for table 'customers' is null
>>>       at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:708)
>>>       at tutim.db.DBCustomersPeer.doInsert(DBCustomersPeer.java:258)
>>>       at tutim.db.DBCustomersPeer.doInsert(DBCustomersPeer.java:636)
>>>       at tutim.db.DBCustomers.save(DBCustomers.java:993)
>>>...
>>>    
>>>
>>
>>You must not only have the table, but you must also have ID entries in it.
>>
>>Folks, I know that this is frustrating, but IMHO the only way to deal with
>>torque in a sane way is:
>>
>>0) use torque 3.1 If you are forced to use 3.2-dev for any reason, you are on
>>   your own (or Scott will help you). Sorry.
>>
>>1) get maven
>>
>>2) get the torque plugin for maven
>>
>>3) get your schema going
>>
>>4) get the following schema file for the ID_TABLE. It is part of the source
>>   distribution of Torque, it is in src/generator/src/schema/id-table-schema.xml
>>
>>--- cut ---
>><?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
>><!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database_3_1.dtd">
>>
>><!-- ==================================================================== -->
>><!--                                                                      -->
>><!-- I D  B R O K E R  S C H E M A                                        -->
>><!--                                                                      -->
>><!-- ==================================================================== -->
>><!-- This is the XML schema use by Torque to generate the SQL for         -->
>><!-- ID_TABLE table used by the id broker mechanism in Torque.            -->
>><!-- ==================================================================== -->
>><!-- @author: <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
      -->
>><!-- @version $Id: id-table-schema.xml,v 1.2 2003/07/24 12:40:41 mpoeschl Exp $
-->
>><!-- ==================================================================== -->
>>
>><database name="@DATABASE_DEFAULT@">
>>  <table name="ID_TABLE" idMethod="idbroker">
>>    <column name="ID_TABLE_ID" required="true" primaryKey="true" type="INTEGER"/>
>>    <column name="TABLE_NAME" required="true" size="255" type="VARCHAR"/>
>>    <column name="NEXT_ID" type="INTEGER"/>
>>    <column name="QUANTITY" type="INTEGER"/>
>>    <unique>
>>      <unique-column name="TABLE_NAME"/>
>>    </unique>
>>  </table>
>></database>
>>--- cut ---
>>
>>Change the database name above as needed.
>>
>>5) run maven torque:sql
>>
>>    => You have the sql files which create your database schema
>>
>>6) run maven torque:id-table-init-sql
>>
>>    => You get an SQL file, which contains the necessary insert 
>>       statements for the ID_TABLE, so that your objects will get
>>       unique ids. You must insert this file into your database by
>>       hand. IF YOU DON'T DO THIS, "NATIVE" OR "IDBROKER" WILL NOT
>>       NOT WORK. I REPEAT: IT WILL NOT WORK.
>>
>>   This file looks something like this:
>>
>>--- cut ---
>>insert into ID_TABLE (id_table_id, id_table_table_name, id_table_next_id, id_table_quantity)
VALUES (1100, 'TURBINE_USER', 100, 10);
>>insert into ID_TABLE (id_table_id, id_table_table_name, id_table_next_id, id_table_quantity)
VALUES (1101, 'TURBINE_PERMISSION', 100, 10);
>>insert into ID_TABLE (id_table_id, id_table_table_name, id_table_next_id, id_table_quantity)
VALUES (1102, 'TURBINE_ROLE', 100, 10);
>>insert into ID_TABLE (id_table_id, id_table_table_name, id_table_next_id, id_table_quantity)
VALUES (1103, 'TURBINE_GROUP', 100, 10);
>>insert into ID_TABLE (id_table_id, id_table_table_name, id_table_next_id, id_table_quantity)
VALUES (1104, 'TURBINE_ROLE_PERMISSION', 100, 10);
>>insert into ID_TABLE (id_table_id, id_table_table_name, id_table_next_id, id_table_quantity)
VALUES (1105, 'TURBINE_USER_GROUP_ROLE', 100, 10);
>>--- cut ---
>>
>>(TURBINE_xxx are my tables. There will be the names of _your_ tables).
>>
>>	Regards
>>		Henning
>>
>>  
>>
>>>a.winter@telenet-ag.de wrote:
>>>    
>>>
>>
>>  
>>
>>>>Hi Ron,
>>>>
>>>>I had the same problem with an oracle database. My solution was to add the

>>>>table ID_TABLE:
>>>>
>>>>       create table ID_TABLE (ID_TABLE_ID  NUMBER(20) NOT NULL, 
>>>>                               TABLE_NAME   VARCHAR2(50)    NOT NULL,
>>>>                               NEXT_ID      NUMBER(20)      NOT NULL,
>>>>                               QUANTITY     NUMBER(20)      NOT NULL)
>>>>
>>>>In my case the table is empty, because I'm using oracle sequence numbers.
>>>>
>>>>Hope that helps,
>>>>Arndt
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>ron piterman <ron.piterman@gmx.net>
>>>>13.07.2004 11:07
>>>>Please respond to "Apache Torque Users List"
>>>>
>>>>
>>>>       To:     Apache Torque Users List <torque-user@db.apache.org>
>>>>       cc: 
>>>>       Subject:        Re: IdGenerator is null
>>>>
>>>>
>>>>I don't know if it mutters, but I also habe:
>>>>torque.idbroker.cleverquantity=true
>>>>
>>>>
>>>>Andras Balogh wrote:
>>>>
>>>> 
>>>>
>>>>      
>>>>
>>>>>Hello,
>>>>>
>>>>>How is your torque.properties file look like?
>>>>>Do you have a line like:
>>>>>torque.database.<yourdb_name>.adapter=mysql
>>>>>?
>>>>>
>>>>>Best regards,
>>>>>Andras.
>>>>>
>>>>>ron piterman wrote:
>>>>>
>>>>>   
>>>>>
>>>>>        
>>>>>
>>>>>>Hi,
>>>>>>I am using torque with mysql, generating the schema vie the ant jdbc

>>>>>>task, and then the obejct model with the om task.
>>>>>>When calling save(connection) on a new object (thus inserting), I
get 
>>>>>>an exception: IdGenerator is null.
>>>>>>in my Map classes, the generator method is set to NATIVE.
>>>>>>What did I forget?
>>>>>>Cheers,
>>>>>>Ron
>>>>>>
>>>>>>
>>>>>>---------------------------------------------------------------------
>>>>>>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
>>>    
>>>
>>
>>  
>>

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

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

"Fighting for one's political stand is an honorable action, but re-
 fusing to acknowledge that there might be weaknesses in one's
 position - in order to identify them so that they can be remedied -
 is a large enough problem with the Open Source movement that it
 deserves to be on this list of the top five problems."
                       -- Michelle Levesque, "Fundamental Issues with
                                    Open Source Software Development"

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


Mime
View raw message