You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Matthew Pomar <ma...@hotmail.com> on 2003/09/03 16:06:06 UTC

One-to-one

Is there anyway to use Turbine (Torque) to create a one-to-one mapping in
the database schema? I'm extending the TURBINE_USER per instructions on
Turbine site:

http://jakarta.apache.org/turbine/turbine-2.2.1/howto/extend-user-howto.html

But instead of creating over 25 new columns in the user table, I'm create a
new USER_PROFILE table with all the additional information. What I'm facing
now is this:

ExtendedUser user = (ExtendedUser)data.getUser();
UserProfile profile = (UserProfile)user.getUserProfiles().get(0);

There is only 1 profile for 1 user - one to one. Instead of the above code,
I would like to do this:

ExtendedUser user = (ExtendedUser)data.getUser();
UserProfile profile = user.getUserProfile();

Can anyone tell me how to accomplish this without extending the ExtendedUser
class?

Thanks

Re: One-to-one

Posted by Michal Frackowiak <mi...@fotoforum.pl>.
Matthew Pomar wrote:

>Is there anyway to use Turbine (Torque) to create a one-to-one mapping in
>the database schema? I'm extending the TURBINE_USER per instructions on
>Turbine site:
>
>http://jakarta.apache.org/turbine/turbine-2.2.1/howto/extend-user-howto.html
>
>But instead of creating over 25 new columns in the user table, I'm create a
>new USER_PROFILE table with all the additional information. What I'm facing
>now is this:
>
>ExtendedUser user = (ExtendedUser)data.getUser();
>UserProfile profile = (UserProfile)user.getUserProfiles().get(0);
>
>There is only 1 profile for 1 user - one to one. Instead of the above code,
>I would like to do this:
>
>ExtendedUser user = (ExtendedUser)data.getUser();
>UserProfile profile = user.getUserProfile();
>
>Can anyone tell me how to accomplish this without extending the ExtendedUser
>class?
>
>  
>
you can do it "manually". just edit ExtendedUser class and add the 
method getUserProfile(). ExtendedUser extends BaseExtendedUser and can 
be modified freely - as you know I suppose.

regrads - michal


Re: One-to-one

Posted by Michal Frackowiak <mi...@fotoforum.pl>.
oh, I am sorry. I should read posts more carefully.
Please forget my post. But I still thik this is not a good way around.

regards - michal

Louis Moore wrote:

>I understand matthew's problem. using a foreign key
>will, in fact, generate getUserProfile(). each entry
>in the EXTENDED_USER table will have exactly ONE
>foreign key to the USER_PROFILE table and torque will
>generate the getUserProfile() function which will
>return the ONE associated profile. i would suggest
>trying this method. 
>
>your schema should look something like this:
>
><table name="EXTENDED_USER">
>  .
>  .
>  <column name="USER_PROFILE_ID" type="INTEGER"/>
>  .
>  .
>  <foreign-key foreignTable="USER_PROFILE">
>    <reference local="USER_PROFILE_ID"
>foreign="USER_PROFILE_ID"/>
>  </foreign-key>
></table>
>
>-Lou
>
>--- Michal Frackowiak <mi...@fotoforum.pl> wrote:
>  
>
>>Louis Moore wrote:
>>
>>    
>>
>>>You can add a USER_PROFILE_ID field to your
>>>EXTENDED_USER table and make it a foreign key to
>>>      
>>>
>>the
>>    
>>
>>>USER_PROFILE table. Then torque should autogenerate
>>>the getUserProfile() function i believe.
>>>
>>>      
>>>
>>no, it will generate getUserProfiles(). and that is
>>not Matthew's 
>>problem but rather getting only ONE profile with
>>getUserProfile().
>>Matthew - see my answer above.... you can implement
>>this method in 
>>ExtendedUser. That is how I do such things.
>>
>>regards - michal
>>
>>    
>>
>>>-Lou
>>>
>>>--- Matthew Pomar <ma...@hotmail.com> wrote:
>>> 
>>>
>>>      
>>>
>>>>Is there anyway to use Turbine (Torque) to create
>>>>        
>>>>
>>a
>>    
>>
>>>>one-to-one mapping in
>>>>the database schema? I'm extending the
>>>>        
>>>>
>>TURBINE_USER
>>    
>>
>>>>per instructions on
>>>>Turbine site:
>>>>
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>http://jakarta.apache.org/turbine/turbine-2.2.1/howto/extend-user-howto.html
>>    
>>
>>> 
>>>
>>>      
>>>
>>>>But instead of creating over 25 new columns in the
>>>>user table, I'm create a
>>>>new USER_PROFILE table with all the additional
>>>>information. What I'm facing
>>>>now is this:
>>>>
>>>>ExtendedUser user = (ExtendedUser)data.getUser();
>>>>UserProfile profile =
>>>>(UserProfile)user.getUserProfiles().get(0);
>>>>
>>>>There is only 1 profile for 1 user - one to one.
>>>>Instead of the above code,
>>>>I would like to do this:
>>>>
>>>>ExtendedUser user = (ExtendedUser)data.getUser();
>>>>UserProfile profile = user.getUserProfile();
>>>>
>>>>Can anyone tell me how to accomplish this without
>>>>extending the ExtendedUser
>>>>class?
>>>>
>>>>Thanks
>>>>
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>---------------------------------------------------------------------
>>    
>>
>>> 
>>>
>>>      
>>>
>>>>To unsubscribe, e-mail:
>>>>turbine-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail:
>>>>turbine-user-help@jakarta.apache.org
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>__________________________________
>>>Do you Yahoo!?
>>>Yahoo! SiteBuilder - Free, easy-to-use web site
>>>      
>>>
>>design software
>>    
>>
>>>http://sitebuilder.yahoo.com
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>    
>>
>>>To unsubscribe, e-mail:
>>>      
>>>
>>turbine-user-unsubscribe@jakarta.apache.org
>>    
>>
>>>For additional commands, e-mail:
>>>      
>>>
>>turbine-user-help@jakarta.apache.org
>>    
>>
>>> 
>>>
>>>      
>>>
>>
>>
>>    
>>
>---------------------------------------------------------------------
>  
>
>>To unsubscribe, e-mail:
>>turbine-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail:
>>turbine-user-help@jakarta.apache.org
>>
>>    
>>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free, easy-to-use web site design software
>http://sitebuilder.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>  
>




Re: One-to-one

Posted by Louis Moore <lr...@yahoo.com>.
I understand matthew's problem. using a foreign key
will, in fact, generate getUserProfile(). each entry
in the EXTENDED_USER table will have exactly ONE
foreign key to the USER_PROFILE table and torque will
generate the getUserProfile() function which will
return the ONE associated profile. i would suggest
trying this method. 

your schema should look something like this:

<table name="EXTENDED_USER">
  .
  .
  <column name="USER_PROFILE_ID" type="INTEGER"/>
  .
  .
  <foreign-key foreignTable="USER_PROFILE">
    <reference local="USER_PROFILE_ID"
foreign="USER_PROFILE_ID"/>
  </foreign-key>
</table>

-Lou

--- Michal Frackowiak <mi...@fotoforum.pl> wrote:
> Louis Moore wrote:
> 
> >You can add a USER_PROFILE_ID field to your
> >EXTENDED_USER table and make it a foreign key to
> the
> >USER_PROFILE table. Then torque should autogenerate
> >the getUserProfile() function i believe.
> >
> no, it will generate getUserProfiles(). and that is
> not Matthew's 
> problem but rather getting only ONE profile with
> getUserProfile().
> Matthew - see my answer above.... you can implement
> this method in 
> ExtendedUser. That is how I do such things.
> 
> regards - michal
> 
> >
> >-Lou
> >
> >--- Matthew Pomar <ma...@hotmail.com> wrote:
> >  
> >
> >>Is there anyway to use Turbine (Torque) to create
> a
> >>one-to-one mapping in
> >>the database schema? I'm extending the
> TURBINE_USER
> >>per instructions on
> >>Turbine site:
> >>
> >>
> >>    
> >>
>
>http://jakarta.apache.org/turbine/turbine-2.2.1/howto/extend-user-howto.html
> >  
> >
> >>But instead of creating over 25 new columns in the
> >>user table, I'm create a
> >>new USER_PROFILE table with all the additional
> >>information. What I'm facing
> >>now is this:
> >>
> >>ExtendedUser user = (ExtendedUser)data.getUser();
> >>UserProfile profile =
> >>(UserProfile)user.getUserProfiles().get(0);
> >>
> >>There is only 1 profile for 1 user - one to one.
> >>Instead of the above code,
> >>I would like to do this:
> >>
> >>ExtendedUser user = (ExtendedUser)data.getUser();
> >>UserProfile profile = user.getUserProfile();
> >>
> >>Can anyone tell me how to accomplish this without
> >>extending the ExtendedUser
> >>class?
> >>
> >>Thanks
> >>
> >>
> >>    
> >>
>
>---------------------------------------------------------------------
> >  
> >
> >>To unsubscribe, e-mail:
> >>turbine-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail:
> >>turbine-user-help@jakarta.apache.org
> >>
> >>    
> >>
> >
> >
> >__________________________________
> >Do you Yahoo!?
> >Yahoo! SiteBuilder - Free, easy-to-use web site
> design software
> >http://sitebuilder.yahoo.com
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> turbine-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail:
> turbine-user-help@jakarta.apache.org
> >
> >  
> >
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> turbine-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: One-to-one

Posted by Michal Frackowiak <mi...@fotoforum.pl>.
Louis Moore wrote:

>You can add a USER_PROFILE_ID field to your
>EXTENDED_USER table and make it a foreign key to the
>USER_PROFILE table. Then torque should autogenerate
>the getUserProfile() function i believe.
>
no, it will generate getUserProfiles(). and that is not Matthew's 
problem but rather getting only ONE profile with getUserProfile().
Matthew - see my answer above.... you can implement this method in 
ExtendedUser. That is how I do such things.

regards - michal

>
>-Lou
>
>--- Matthew Pomar <ma...@hotmail.com> wrote:
>  
>
>>Is there anyway to use Turbine (Torque) to create a
>>one-to-one mapping in
>>the database schema? I'm extending the TURBINE_USER
>>per instructions on
>>Turbine site:
>>
>>
>>    
>>
>http://jakarta.apache.org/turbine/turbine-2.2.1/howto/extend-user-howto.html
>  
>
>>But instead of creating over 25 new columns in the
>>user table, I'm create a
>>new USER_PROFILE table with all the additional
>>information. What I'm facing
>>now is this:
>>
>>ExtendedUser user = (ExtendedUser)data.getUser();
>>UserProfile profile =
>>(UserProfile)user.getUserProfiles().get(0);
>>
>>There is only 1 profile for 1 user - one to one.
>>Instead of the above code,
>>I would like to do this:
>>
>>ExtendedUser user = (ExtendedUser)data.getUser();
>>UserProfile profile = user.getUserProfile();
>>
>>Can anyone tell me how to accomplish this without
>>extending the ExtendedUser
>>class?
>>
>>Thanks
>>
>>
>>    
>>
>---------------------------------------------------------------------
>  
>
>>To unsubscribe, e-mail:
>>turbine-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail:
>>turbine-user-help@jakarta.apache.org
>>
>>    
>>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free, easy-to-use web site design software
>http://sitebuilder.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>  
>



Re: One-to-one

Posted by Louis Moore <lr...@yahoo.com>.
You can add a USER_PROFILE_ID field to your
EXTENDED_USER table and make it a foreign key to the
USER_PROFILE table. Then torque should autogenerate
the getUserProfile() function i believe.

-Lou

--- Matthew Pomar <ma...@hotmail.com> wrote:
> Is there anyway to use Turbine (Torque) to create a
> one-to-one mapping in
> the database schema? I'm extending the TURBINE_USER
> per instructions on
> Turbine site:
> 
>
http://jakarta.apache.org/turbine/turbine-2.2.1/howto/extend-user-howto.html
> 
> But instead of creating over 25 new columns in the
> user table, I'm create a
> new USER_PROFILE table with all the additional
> information. What I'm facing
> now is this:
> 
> ExtendedUser user = (ExtendedUser)data.getUser();
> UserProfile profile =
> (UserProfile)user.getUserProfiles().get(0);
> 
> There is only 1 profile for 1 user - one to one.
> Instead of the above code,
> I would like to do this:
> 
> ExtendedUser user = (ExtendedUser)data.getUser();
> UserProfile profile = user.getUserProfile();
> 
> Can anyone tell me how to accomplish this without
> extending the ExtendedUser
> class?
> 
> Thanks
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> turbine-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com