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 "thomas.ung@freesbee.fr" <th...@freesbee.fr> on 2006/05/15 01:59:17 UTC

Re: Extending torque user - documentation issue?

Thanks a lot Helge for your answer! I am not sure but I think that I am not going to extend TURBINE_USER. but create a new table instead like in scarab USER_PREFERENCE

But for the 'fun', I ve tried both methods ;-)

>>>>>>> 1st - I ve extended the TUBINE_USER in my-project-schema.xml. <<<<<<<<
  * I've added a new column called 'LOCALEID'

  <table name="USER" idMethod="native"
         baseClass="org.apache.turbine.services.security.torque.om.BaseTurbineUser"
         basePeer="org.apache.turbine.services.security.torque.om.BaseTurbineUserPeer">
    ...
    <column name="LOCALEID"       type="INTEGER"                                 javaName="LocaleId"/>
    ...

  * I've ran maven torque:create-db, torque:sql then torque:insert-sql
  * maven turbine:deploy

but I got 'incompatible return type' errors from generated BaseUser.java and BaseUserPeer.java:
    found   : com.bobo.om.User - required: org.apache.turbine.services.security.torque.om.TurbineUser
or found   : com.bobo.om.UserPeer - required: org.apache.turbine.services.security.torque.om.TurbineUserPeer

So I've try to change my new generated User.java and UserPeer to extend them to TurbineUser/TorqueUser and TurbineUserPeer [as specified from documentation 'torque-security-service.html'(?)]

I did not change TR.properties yet because I got lots of incompatible type errors ... very very tricky....

> you can specify the base class for Torque to use for any table in your schema. Same for peer base classes. Have a look at http://db.apache.org/torque/releases/torque-3.2/generator/schema-reference.html for details.

Helge, it seems that even by setting 
         baseClass="org.apache.turbine.services.security.torque.om.BaseTurbineUser"
         basePeer="org.apache.turbine.services.security.torque.om.BaseTurbineUserPeer">
Torque generator still generate the same classe that extends 'BaseExtendedUser'....

> According to the portion of code provided, how the system knows  
> that we should use the EXTENDED_USER table in the db instead of  
> TURBINE_USER table? the extended table is not  TURBINE_USER but  
> EXTENDED_USER  table!

so I choose not to extend turbine_user but create a table 'user_preference' like in turbine

>>>>>>> 2nd - I ve created a new table 'USER_PREFERENCE' like in scarab db. <<<<<<<<
  * I've added a new table

  <table name="USER_PREFERENCE" idMethod="none" ...>
    <column name="USER_ID"        .../> ...
    <foreign-key foreignTable="TURBINE_USER"><reference local="USER_ID" foreign="USER_ID"/></foreign-key>
    ...

by running $maven torque:create-db , I got an error:
org.apache.torque.engine.EngineException: Attempt to set foreign key to nonexistent table, TURBINE_USER

  * so like in project scarab, i've add the following in my project-schema.xml

<table name="TURBINE_USER" 
    baseClass="org.apache.turbine.services.security.torque.om.TurbineUser"
    basePeer="org.apache.turbine.services.security.torque.om.TurbineUserPeer>
    <column name="USER_ID" primaryKey="true" required="true" type="INTEGER"/>
</table>

  * torque:create-db and torque:sql run well

  * but I got some errors by inserting sql (torque:insert-sql)

[torque-sql-exec] [ERROR] Failed to execute:drop table if exists TURBINE_USER
[torque-sql-exec] [ERROR] java.sql.SQLException: null,  message from server: "Cannot delete or update a parent row: a foreign key constraint fails"

[torque-sql-exec] [ERROR] Failed to execute: CREATE TABLE TURBINE_USER ...
[torque-sql-exec] [ERROR] java.sql.SQLException: null,  message from server: "Table 'turbine_user' already exists"

looks normal (???) because TURBINE_USER exists in turbine-schema.xml

Here, I was supprise because I got the same errors that in the 1st method

attempting to use incompatible return type
found   : com.bobo.om.TurbineUser
required: org.apache.turbine.services.security.torque.om.TurbineUser


I understand that this is pretty hard to read, because it requires some time to understand what I am trying to explain, but I will really appraciate for any help!

Regards,
Thomas



-------------- ALICE HAUT DEBIT : TRIPLE PLAY A 29,95 EUR/MOIS -------------- 
Découvrez vite ALICEBOX : avec le modem WIFI, profitez de l'ADSL, de la TELEPHONIE et en exclusivité de la TELEVISION ! 
Bénéficiez aussi de la hotline gratuite 24h/24 ! Soumis à conditions. Pour en profiter cliquez ici http://abonnement.aliceadsl.fr





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