You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Alen Ribic <al...@mweb.co.za> on 2003/06/03 10:36:20 UTC

Extent. How to?

Hi again

I have sent an email already and got a good reply, but now I have an issue
with mapping side.

I have got classes as follows:

// JavaBean
public class User extends ValidatorForm {}

// Struts form bean
public class RegisterForm extends User {}

Now I just need OJB to recognize RegisteForm class as a User.

usr = request.getAttribute("registerForm"); // returns RegisteForm instance
broker.store(usr);

So now, OJB on store(...) should look at mapping for User class to User
table.

  <class-descriptor
      class="za.co.alen.jfaq.User"
      table="User"
   >
      <extent-class class-ref="za.co.alen.struts.RegisterForm" />
      <!-- field mappings -->
      ...
   </class-descriptor>

I presume that now I need a <class-descriptor/> for the RegisterForm class.
Is this correct?
I looked at the Article example but I just can't get my one to work.

My app still says that OJB cannot recognize RegisterForm class in
repository.

What am I doing wrong and how can I go about doing this correctly.

Thanks

--Alen



Re: Extent. How to?

Posted by Alen Ribic <al...@mweb.co.za>.
thanks again.

----- Original Message -----
From: "Thomas Mahler" <th...@web.de>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Tuesday, June 03, 2003 6:19 PM
Subject: Re: Extent. How to?


> Hi again Alen,
>
> try this:
>      <class-descriptor class="ValidatorForm">
>         <extent-class class-ref="za.co.alen.jfaq.User" />
>      </class-descriptor>
>
>      <class-descriptor
>        class="za.co.alen.jfaq.User"
>        table="User"
>        <extent-class class-ref="za.co.alen.jfaq.RegisterForm" />
>        <extent-class class-ref="za.co.alen.jfaq.LgonForm" />
>      >
>        <!-- field mappings -->
>        ...
>      </class-descriptor>
>
>      <class-descriptor
>        class="za.co.alen.jfaq.RegisterForm"
>        table="User"
>      >
>        <!-- same field mappings as for User class + possibly some more -->
>        ...
>      </class-descriptor>
>
>      <class-descriptor
>        class="za.co.alen.jfaq.LogonForm"
>        table="User"
>      >
>        <!-- same field mappings as for User class + possibly some
ore  -->
>        ...
>      </class-descriptor>
>
> You should also have a look at the repository_junit.xml, it contains *a
> lot* of inheritance examples!
>
> cheers,
> Thomas
>
>
>
> Alen Ribic wrote:
> > Ok I'm back again on this one.
> > Lets try this again.
> >
> > My objective:
> >
> > Using Struts, I will need to create form bean for each Struts form.
> >
> > So, for example, I will create RegisterForm and LogonForm classes.
> > As you can se now, these two classes will have similarities in their
> > getter/setter methods.
> >
> > Hence I would like to Create a single User class that all these similar
form
> > beans can inherit.
> >
> > public class RegisterForm extends User {
> >     // inherits necessary setters/getters from User class
> >     public ... validate(...) { // override superclasses version
> >     }
> > }
> >
> > public class LogonForm extends User {
> >     // inherits necessary setters/getters from User class
> >     public ... validate(...) { // override superclasses version
> >     }
> > }
> >
> > Now I want my form beans also to inherit ValidatorForm class.
> >
> > So, I add extends on User class as follows: (don't really think this one
is
> > cool, but anyway, it works :) )
> >
> > public class User extends ValidatorForm {
> >     // setter/getter properties
> > }
> >
> > As far as Struts side of things, this seems to be working fine so far.
> >
> > Only reason I make use of form classes here that inherit my User class
is
> > because of validation requirements specific to each individual form.
(needed
> > in my Struts config) Now there is no way I'm rewriting my User specific
> > setter/getter properties for each of my forms, e.g. RegisterForm,
LogonForm.
> > Both of these form beans will contain common setter/getter properties
which
> > need to map to the same table called User.
> >
> > Again, if I need to specify for each form bean (RegisterForm, LogonForm)
a
> > separate class descriptor with it's own, SAME, fields, it would just
suck a
> > bit.
> >
> > Hope this time I come roght. :)
> >
> > I really appreciate your help.
> > --Alen
> >
> >
> >
> > ----- Original Message -----
> > From: "Thomas Mahler" <th...@web.de>
> > To: "OJB Users List" <oj...@db.apache.org>
> > Sent: Tuesday, June 03, 2003 11:43 AM
> > Subject: Re: Extent. How to?
> >
> >
> >
> >>Hi again Alen.
> >>
> >>I think you should define the extent the other way round.
> >>That is: RegisterForm is the abstract base class and User is the
> >>concrete class defining all the persistent attributes.
> >>
> >>    <class-descriptor class="za.co.alen.struts.RegisterForm">
> >>       <extent-class class-ref="za.co.alen.jfaq.User" />
> >>    </class-descriptor>
> >>
> >>    <class-descriptor
> >>      class="za.co.alen.jfaq.User"
> >>      table="User"
> >>    >
> >>      <!-- field mappings -->
> >>      ...
> >>    </class-descriptor>
> >>
> >>cheers,
> >>Thomas
> >>
> >>Alen Ribic wrote:
> >>
> >>>Thanks Raymond for your reply.
> >>>
> >>>This is the thing. I am very lost.
> >>>The User class descriptor in repository contains all my filed mappings
> >
> > to my
> >
> >>>User table in db.
> >>>Now za.co.alen.struts.RegisterForm class mapping is a very good
> >
> > question.
> >
> >>>What would the za.co.alen.struts.RegisterForm class mapping contain? I
> >
> > don't
> >
> >>>need any RegisterForm class specific fields at all.
> >>>I just need to indicate to OJB that it needs to something like cast
> >>>RegisterForm instance to User and hence would need to map that to User
> >
> > class
> >
> >>>/ table mapping. (Remember that the instance I get is of
> >>>za.co.alen.struts.RegisterForm)
> >>>RegisterForm class does not have any real meaning for persistence
> >
> > besides
> >
> >>>the inherited fields from User bean.
> >>>It basically just contains overridden validate(...) method used for
> >>>server-side validation in my struts components.
> >>>
> >>>I hope this is making sense. :-)
> >>>
> >>>--Alen
> >>>
> >>>
> >>>
> >>>----- Original Message -----
> >>>From: "Raymond Barlow" <rb...@raymanoz.com>
> >>>To: "OJB Users List" <oj...@db.apache.org>
> >>>Sent: Tuesday, June 03, 2003 10:45 AM
> >>>Subject: Re: Extent. How to?
> >>>
> >>>
> >>>
> >>>
> >>>>Hi Alen
> >>>>
> >>>>I hate to ask the obvious, but you never know :)
> >>>>Have you created a mapping for za.co.alen.struts.RegisterForm in your
> >>>>repository_user.xml file??
> >>>>
> >>>>Regards,
> >>>>Raymond Barlow
> >>>>
> >>>>Alen Ribic wrote:
> >>>>
> >>>>
> >>>>
> >>>>>Hi again
> >>>>>
> >>>>>I have sent an email already and got a good reply, but now I have an
> >>>
> >>>issue
> >>>
> >>>
> >>>>>with mapping side.
> >>>>>
> >>>>>I have got classes as follows:
> >>>>>
> >>>>>// JavaBean
> >>>>>public class User extends ValidatorForm {}
> >>>>>
> >>>>>// Struts form bean
> >>>>>public class RegisterForm extends User {}
> >>>>>
> >>>>>Now I just need OJB to recognize RegisteForm class as a User.
> >>>>>
> >>>>>usr = request.getAttribute("registerForm"); // returns RegisteForm
> >>>
> >>>instance
> >>>
> >>>
> >>>>>broker.store(usr);
> >>>>>
> >>>>>So now, OJB on store(...) should look at mapping for User class to
User
> >>>>>table.
> >>>>>
> >>>>><class-descriptor
> >>>>>    class="za.co.alen.jfaq.User"
> >>>>>    table="User"
> >>>>> >
> >>>>>    <extent-class class-ref="za.co.alen.struts.RegisterForm" />
> >>>>>    <!-- field mappings -->
> >>>>>    ...
> >>>>> </class-descriptor>
> >>>>>
> >>>>>I presume that now I need a <class-descriptor/> for the RegisterForm
> >>>
> >>>class.
> >>>
> >>>
> >>>>>Is this correct?
> >>>>>I looked at the Article example but I just can't get my one to work.
> >>>>>
> >>>>>My app still says that OJB cannot recognize RegisterForm class in
> >>>>>repository.
> >>>>>
> >>>>>What am I doing wrong and how can I go about doing this correctly.
> >>>>>
> >>>>>Thanks
> >>>>>
> >>>>>--Alen
> >>>>>
> >>>>>
> >>>>>
> >>>>>---------------------------------------------------------------------
> >>>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>>>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>>
> >>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>
> >>>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>



Re: Extent. How to?

Posted by Thomas Mahler <th...@web.de>.
Hi again Alen,

try this:
     <class-descriptor class="ValidatorForm">
        <extent-class class-ref="za.co.alen.jfaq.User" />
     </class-descriptor>

     <class-descriptor
       class="za.co.alen.jfaq.User"
       table="User"
       <extent-class class-ref="za.co.alen.jfaq.RegisterForm" />
       <extent-class class-ref="za.co.alen.jfaq.LgonForm" />
     >
       <!-- field mappings -->
       ...
     </class-descriptor>

     <class-descriptor
       class="za.co.alen.jfaq.RegisterForm"
       table="User"
     >
       <!-- same field mappings as for User class + possibly some more -->
       ...
     </class-descriptor>

     <class-descriptor
       class="za.co.alen.jfaq.LogonForm"
       table="User"
     >
       <!-- same field mappings as for User class + possibly some more  -->
       ...
     </class-descriptor>

You should also have a look at the repository_junit.xml, it contains *a 
lot* of inheritance examples!

cheers,
Thomas



Alen Ribic wrote:
> Ok I'm back again on this one.
> Lets try this again.
> 
> My objective:
> 
> Using Struts, I will need to create form bean for each Struts form.
> 
> So, for example, I will create RegisterForm and LogonForm classes.
> As you can se now, these two classes will have similarities in their
> getter/setter methods.
> 
> Hence I would like to Create a single User class that all these similar form
> beans can inherit.
> 
> public class RegisterForm extends User {
>     // inherits necessary setters/getters from User class
>     public ... validate(...) { // override superclasses version
>     }
> }
> 
> public class LogonForm extends User {
>     // inherits necessary setters/getters from User class
>     public ... validate(...) { // override superclasses version
>     }
> }
> 
> Now I want my form beans also to inherit ValidatorForm class.
> 
> So, I add extends on User class as follows: (don't really think this one is
> cool, but anyway, it works :) )
> 
> public class User extends ValidatorForm {
>     // setter/getter properties
> }
> 
> As far as Struts side of things, this seems to be working fine so far.
> 
> Only reason I make use of form classes here that inherit my User class is
> because of validation requirements specific to each individual form. (needed
> in my Struts config) Now there is no way I'm rewriting my User specific
> setter/getter properties for each of my forms, e.g. RegisterForm, LogonForm.
> Both of these form beans will contain common setter/getter properties which
> need to map to the same table called User.
> 
> Again, if I need to specify for each form bean (RegisterForm, LogonForm) a
> separate class descriptor with it's own, SAME, fields, it would just suck a
> bit.
> 
> Hope this time I come roght. :)
> 
> I really appreciate your help.
> --Alen
> 
> 
> 
> ----- Original Message -----
> From: "Thomas Mahler" <th...@web.de>
> To: "OJB Users List" <oj...@db.apache.org>
> Sent: Tuesday, June 03, 2003 11:43 AM
> Subject: Re: Extent. How to?
> 
> 
> 
>>Hi again Alen.
>>
>>I think you should define the extent the other way round.
>>That is: RegisterForm is the abstract base class and User is the
>>concrete class defining all the persistent attributes.
>>
>>    <class-descriptor class="za.co.alen.struts.RegisterForm">
>>       <extent-class class-ref="za.co.alen.jfaq.User" />
>>    </class-descriptor>
>>
>>    <class-descriptor
>>      class="za.co.alen.jfaq.User"
>>      table="User"
>>    >
>>      <!-- field mappings -->
>>      ...
>>    </class-descriptor>
>>
>>cheers,
>>Thomas
>>
>>Alen Ribic wrote:
>>
>>>Thanks Raymond for your reply.
>>>
>>>This is the thing. I am very lost.
>>>The User class descriptor in repository contains all my filed mappings
> 
> to my
> 
>>>User table in db.
>>>Now za.co.alen.struts.RegisterForm class mapping is a very good
> 
> question.
> 
>>>What would the za.co.alen.struts.RegisterForm class mapping contain? I
> 
> don't
> 
>>>need any RegisterForm class specific fields at all.
>>>I just need to indicate to OJB that it needs to something like cast
>>>RegisterForm instance to User and hence would need to map that to User
> 
> class
> 
>>>/ table mapping. (Remember that the instance I get is of
>>>za.co.alen.struts.RegisterForm)
>>>RegisterForm class does not have any real meaning for persistence
> 
> besides
> 
>>>the inherited fields from User bean.
>>>It basically just contains overridden validate(...) method used for
>>>server-side validation in my struts components.
>>>
>>>I hope this is making sense. :-)
>>>
>>>--Alen
>>>
>>>
>>>
>>>----- Original Message -----
>>>From: "Raymond Barlow" <rb...@raymanoz.com>
>>>To: "OJB Users List" <oj...@db.apache.org>
>>>Sent: Tuesday, June 03, 2003 10:45 AM
>>>Subject: Re: Extent. How to?
>>>
>>>
>>>
>>>
>>>>Hi Alen
>>>>
>>>>I hate to ask the obvious, but you never know :)
>>>>Have you created a mapping for za.co.alen.struts.RegisterForm in your
>>>>repository_user.xml file??
>>>>
>>>>Regards,
>>>>Raymond Barlow
>>>>
>>>>Alen Ribic wrote:
>>>>
>>>>
>>>>
>>>>>Hi again
>>>>>
>>>>>I have sent an email already and got a good reply, but now I have an
>>>
>>>issue
>>>
>>>
>>>>>with mapping side.
>>>>>
>>>>>I have got classes as follows:
>>>>>
>>>>>// JavaBean
>>>>>public class User extends ValidatorForm {}
>>>>>
>>>>>// Struts form bean
>>>>>public class RegisterForm extends User {}
>>>>>
>>>>>Now I just need OJB to recognize RegisteForm class as a User.
>>>>>
>>>>>usr = request.getAttribute("registerForm"); // returns RegisteForm
>>>
>>>instance
>>>
>>>
>>>>>broker.store(usr);
>>>>>
>>>>>So now, OJB on store(...) should look at mapping for User class to User
>>>>>table.
>>>>>
>>>>><class-descriptor
>>>>>    class="za.co.alen.jfaq.User"
>>>>>    table="User"
>>>>> >
>>>>>    <extent-class class-ref="za.co.alen.struts.RegisterForm" />
>>>>>    <!-- field mappings -->
>>>>>    ...
>>>>> </class-descriptor>
>>>>>
>>>>>I presume that now I need a <class-descriptor/> for the RegisterForm
>>>
>>>class.
>>>
>>>
>>>>>Is this correct?
>>>>>I looked at the Article example but I just can't get my one to work.
>>>>>
>>>>>My app still says that OJB cannot recognize RegisterForm class in
>>>>>repository.
>>>>>
>>>>>What am I doing wrong and how can I go about doing this correctly.
>>>>>
>>>>>Thanks
>>>>>
>>>>>--Alen
>>>>>
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


Re: Extent. How to?

Posted by Raymond Barlow <rb...@raymanoz.com>.
Hi Alen,

To me, this just sounds like a design issue. The persistent class is 
User, right? I feel that that is the only class out of the 3 classes you 
mentioned that should be OJB controlled. Like I said earlier, have you 
considered aggregating the User class into the RegisterForm and 
LogonForm classes? If required, they could implement the same interface.

I don't really know the design of your system, or how you want it to 
work, but for me it would be natural for the User class to be seperate 
from the Form classes. Maybe in the constructor of the Form classes, you 
can pass a user as a parameter. User can be a property of the forms (ie. 
for works with user object).

What are your thoughts?

-Raymond Barlow


Alen Ribic wrote:

>Ok I'm back again on this one.
>Lets try this again.
>
>My objective:
>
>Using Struts, I will need to create form bean for each Struts form.
>
>So, for example, I will create RegisterForm and LogonForm classes.
>As you can se now, these two classes will have similarities in their
>getter/setter methods.
>
>Hence I would like to Create a single User class that all these similar form
>beans can inherit.
>
>public class RegisterForm extends User {
>    // inherits necessary setters/getters from User class
>    public ... validate(...) { // override superclasses version
>    }
>}
>
>public class LogonForm extends User {
>    // inherits necessary setters/getters from User class
>    public ... validate(...) { // override superclasses version
>    }
>}
>
>Now I want my form beans also to inherit ValidatorForm class.
>
>So, I add extends on User class as follows: (don't really think this one is
>cool, but anyway, it works :) )
>
>public class User extends ValidatorForm {
>    // setter/getter properties
>}
>
>As far as Struts side of things, this seems to be working fine so far.
>
>Only reason I make use of form classes here that inherit my User class is
>because of validation requirements specific to each individual form. (needed
>in my Struts config) Now there is no way I'm rewriting my User specific
>setter/getter properties for each of my forms, e.g. RegisterForm, LogonForm.
>Both of these form beans will contain common setter/getter properties which
>need to map to the same table called User.
>
>Again, if I need to specify for each form bean (RegisterForm, LogonForm) a
>separate class descriptor with it's own, SAME, fields, it would just suck a
>bit.
>
>Hope this time I come roght. :)
>
>I really appreciate your help.
>--Alen
>
>
>
>  
>
<snip>



Re: Extent. How to?

Posted by Alen Ribic <al...@mweb.co.za>.
Ok I'm back again on this one.
Lets try this again.

My objective:

Using Struts, I will need to create form bean for each Struts form.

So, for example, I will create RegisterForm and LogonForm classes.
As you can se now, these two classes will have similarities in their
getter/setter methods.

Hence I would like to Create a single User class that all these similar form
beans can inherit.

public class RegisterForm extends User {
    // inherits necessary setters/getters from User class
    public ... validate(...) { // override superclasses version
    }
}

public class LogonForm extends User {
    // inherits necessary setters/getters from User class
    public ... validate(...) { // override superclasses version
    }
}

Now I want my form beans also to inherit ValidatorForm class.

So, I add extends on User class as follows: (don't really think this one is
cool, but anyway, it works :) )

public class User extends ValidatorForm {
    // setter/getter properties
}

As far as Struts side of things, this seems to be working fine so far.

Only reason I make use of form classes here that inherit my User class is
because of validation requirements specific to each individual form. (needed
in my Struts config) Now there is no way I'm rewriting my User specific
setter/getter properties for each of my forms, e.g. RegisterForm, LogonForm.
Both of these form beans will contain common setter/getter properties which
need to map to the same table called User.

Again, if I need to specify for each form bean (RegisterForm, LogonForm) a
separate class descriptor with it's own, SAME, fields, it would just suck a
bit.

Hope this time I come roght. :)

I really appreciate your help.
--Alen



----- Original Message -----
From: "Thomas Mahler" <th...@web.de>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Tuesday, June 03, 2003 11:43 AM
Subject: Re: Extent. How to?


> Hi again Alen.
>
> I think you should define the extent the other way round.
> That is: RegisterForm is the abstract base class and User is the
> concrete class defining all the persistent attributes.
>
>     <class-descriptor class="za.co.alen.struts.RegisterForm">
>        <extent-class class-ref="za.co.alen.jfaq.User" />
>     </class-descriptor>
>
>     <class-descriptor
>       class="za.co.alen.jfaq.User"
>       table="User"
>     >
>       <!-- field mappings -->
>       ...
>     </class-descriptor>
>
> cheers,
> Thomas
>
> Alen Ribic wrote:
> > Thanks Raymond for your reply.
> >
> > This is the thing. I am very lost.
> > The User class descriptor in repository contains all my filed mappings
to my
> > User table in db.
> > Now za.co.alen.struts.RegisterForm class mapping is a very good
question.
> > What would the za.co.alen.struts.RegisterForm class mapping contain? I
don't
> > need any RegisterForm class specific fields at all.
> > I just need to indicate to OJB that it needs to something like cast
> > RegisterForm instance to User and hence would need to map that to User
class
> > / table mapping. (Remember that the instance I get is of
> > za.co.alen.struts.RegisterForm)
> > RegisterForm class does not have any real meaning for persistence
besides
> > the inherited fields from User bean.
> > It basically just contains overridden validate(...) method used for
> > server-side validation in my struts components.
> >
> > I hope this is making sense. :-)
> >
> > --Alen
> >
> >
> >
> > ----- Original Message -----
> > From: "Raymond Barlow" <rb...@raymanoz.com>
> > To: "OJB Users List" <oj...@db.apache.org>
> > Sent: Tuesday, June 03, 2003 10:45 AM
> > Subject: Re: Extent. How to?
> >
> >
> >
> >>Hi Alen
> >>
> >>I hate to ask the obvious, but you never know :)
> >>Have you created a mapping for za.co.alen.struts.RegisterForm in your
> >>repository_user.xml file??
> >>
> >>Regards,
> >>Raymond Barlow
> >>
> >>Alen Ribic wrote:
> >>
> >>
> >>>Hi again
> >>>
> >>>I have sent an email already and got a good reply, but now I have an
> >
> > issue
> >
> >>>with mapping side.
> >>>
> >>>I have got classes as follows:
> >>>
> >>>// JavaBean
> >>>public class User extends ValidatorForm {}
> >>>
> >>>// Struts form bean
> >>>public class RegisterForm extends User {}
> >>>
> >>>Now I just need OJB to recognize RegisteForm class as a User.
> >>>
> >>>usr = request.getAttribute("registerForm"); // returns RegisteForm
> >
> > instance
> >
> >>>broker.store(usr);
> >>>
> >>>So now, OJB on store(...) should look at mapping for User class to User
> >>>table.
> >>>
> >>> <class-descriptor
> >>>     class="za.co.alen.jfaq.User"
> >>>     table="User"
> >>>  >
> >>>     <extent-class class-ref="za.co.alen.struts.RegisterForm" />
> >>>     <!-- field mappings -->
> >>>     ...
> >>>  </class-descriptor>
> >>>
> >>>I presume that now I need a <class-descriptor/> for the RegisterForm
> >
> > class.
> >
> >>>Is this correct?
> >>>I looked at the Article example but I just can't get my one to work.
> >>>
> >>>My app still says that OJB cannot recognize RegisterForm class in
> >>>repository.
> >>>
> >>>What am I doing wrong and how can I go about doing this correctly.
> >>>
> >>>Thanks
> >>>
> >>>--Alen
> >>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>
> >>>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>


Re: Extent. How to?

Posted by Thomas Mahler <th...@web.de>.
Hi again Alen.

I think you should define the extent the other way round.
That is: RegisterForm is the abstract base class and User is the 
concrete class defining all the persistent attributes.

    <class-descriptor class="za.co.alen.struts.RegisterForm">
       <extent-class class-ref="za.co.alen.jfaq.User" />
    </class-descriptor>

    <class-descriptor
      class="za.co.alen.jfaq.User"
      table="User"
    >
      <!-- field mappings -->
      ...
    </class-descriptor>

cheers,
Thomas

Alen Ribic wrote:
> Thanks Raymond for your reply.
> 
> This is the thing. I am very lost.
> The User class descriptor in repository contains all my filed mappings to my
> User table in db.
> Now za.co.alen.struts.RegisterForm class mapping is a very good question.
> What would the za.co.alen.struts.RegisterForm class mapping contain? I don't
> need any RegisterForm class specific fields at all.
> I just need to indicate to OJB that it needs to something like cast
> RegisterForm instance to User and hence would need to map that to User class
> / table mapping. (Remember that the instance I get is of
> za.co.alen.struts.RegisterForm)
> RegisterForm class does not have any real meaning for persistence besides
> the inherited fields from User bean.
> It basically just contains overridden validate(...) method used for
> server-side validation in my struts components.
> 
> I hope this is making sense. :-)
> 
> --Alen
> 
> 
> 
> ----- Original Message -----
> From: "Raymond Barlow" <rb...@raymanoz.com>
> To: "OJB Users List" <oj...@db.apache.org>
> Sent: Tuesday, June 03, 2003 10:45 AM
> Subject: Re: Extent. How to?
> 
> 
> 
>>Hi Alen
>>
>>I hate to ask the obvious, but you never know :)
>>Have you created a mapping for za.co.alen.struts.RegisterForm in your
>>repository_user.xml file??
>>
>>Regards,
>>Raymond Barlow
>>
>>Alen Ribic wrote:
>>
>>
>>>Hi again
>>>
>>>I have sent an email already and got a good reply, but now I have an
> 
> issue
> 
>>>with mapping side.
>>>
>>>I have got classes as follows:
>>>
>>>// JavaBean
>>>public class User extends ValidatorForm {}
>>>
>>>// Struts form bean
>>>public class RegisterForm extends User {}
>>>
>>>Now I just need OJB to recognize RegisteForm class as a User.
>>>
>>>usr = request.getAttribute("registerForm"); // returns RegisteForm
> 
> instance
> 
>>>broker.store(usr);
>>>
>>>So now, OJB on store(...) should look at mapping for User class to User
>>>table.
>>>
>>> <class-descriptor
>>>     class="za.co.alen.jfaq.User"
>>>     table="User"
>>>  >
>>>     <extent-class class-ref="za.co.alen.struts.RegisterForm" />
>>>     <!-- field mappings -->
>>>     ...
>>>  </class-descriptor>
>>>
>>>I presume that now I need a <class-descriptor/> for the RegisterForm
> 
> class.
> 
>>>Is this correct?
>>>I looked at the Article example but I just can't get my one to work.
>>>
>>>My app still says that OJB cannot recognize RegisterForm class in
>>>repository.
>>>
>>>What am I doing wrong and how can I go about doing this correctly.
>>>
>>>Thanks
>>>
>>>--Alen
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


Re: Extent. How to?

Posted by Alen Ribic <al...@mweb.co.za>.
thanks again.
I'll look into this a bit more from app design point of view.
--Alen

----- Original Message -----
From: "Raymond Barlow" <rb...@raymanoz.com>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Tuesday, June 03, 2003 11:28 AM
Subject: Re: Extent. How to?


> Hi Alen,
>
> I'm fairly new to OJB, but I'm pretty sure that you would have to define
> a class-descriptor for the RegisterForm class. Just try this for now to
> see if it fixes your problem: copy the entire User class descriptor into
> a new RegisterForm class descriptor and just change the relevant bits
> (ie. class="za.co.alen.struts.RegisterForm").
>
> It is a pain, but I think OJB needs to know how to map each extent class
> individually. There has been some postings about using "this" to extend
> mappings, but I've not been able to get this to work successfully.
>
> Just thinking about your problem a bit futher, how is OJB to
> differentiate between a User class and a RegisterForm class when
> searching for a class? ie. If RegisterForm is the same table and
> persistent fields as User, then how can OJB tell if it should be giving
> you a User class or a RegisterForm class? Maybe an alternative for you
> is to have RegisterForm contain an aggregated User class? This way you
> could search for User, then create your RegisterForm class passing the
> relevant User class. Just some ideas....
>
> Regards,
> Raymond Barlow
>
> Alen Ribic wrote:
>
> >Thanks Raymond for your reply.
> >
> >This is the thing. I am very lost.
> >The User class descriptor in repository contains all my filed mappings to
my
> >User table in db.
> >Now za.co.alen.struts.RegisterForm class mapping is a very good question.
> >What would the za.co.alen.struts.RegisterForm class mapping contain? I
don't
> >need any RegisterForm class specific fields at all.
> >I just need to indicate to OJB that it needs to something like cast
> >RegisterForm instance to User and hence would need to map that to User
class
> >/ table mapping. (Remember that the instance I get is of
> >za.co.alen.struts.RegisterForm)
> >RegisterForm class does not have any real meaning for persistence besides
> >the inherited fields from User bean.
> >It basically just contains overridden validate(...) method used for
> >server-side validation in my struts components.
> >
> >I hope this is making sense. :-)
> >
> >--Alen
> >
> >
> >
> >----- Original Message -----
> >From: "Raymond Barlow" <rb...@raymanoz.com>
> >To: "OJB Users List" <oj...@db.apache.org>
> >Sent: Tuesday, June 03, 2003 10:45 AM
> >Subject: Re: Extent. How to?
> >
> >
> >
> >
> >>Hi Alen
> >>
> >>I hate to ask the obvious, but you never know :)
> >>Have you created a mapping for za.co.alen.struts.RegisterForm in your
> >>repository_user.xml file??
> >>
> >>Regards,
> >>Raymond Barlow
> >>
> >>Alen Ribic wrote:
> >>
> >>
> >>
> >>>Hi again
> >>>
> >>>I have sent an email already and got a good reply, but now I have an
> >>>
> >>>
> >issue
> >
> >
> >>>with mapping side.
> >>>
> >>>I have got classes as follows:
> >>>
> >>>// JavaBean
> >>>public class User extends ValidatorForm {}
> >>>
> >>>// Struts form bean
> >>>public class RegisterForm extends User {}
> >>>
> >>>Now I just need OJB to recognize RegisteForm class as a User.
> >>>
> >>>usr = request.getAttribute("registerForm"); // returns RegisteForm
> >>>
> >>>
> >instance
> >
> >
> >>>broker.store(usr);
> >>>
> >>>So now, OJB on store(...) should look at mapping for User class to User
> >>>table.
> >>>
> >>> <class-descriptor
> >>>     class="za.co.alen.jfaq.User"
> >>>     table="User"
> >>>  >
> >>>     <extent-class class-ref="za.co.alen.struts.RegisterForm" />
> >>>     <!-- field mappings -->
> >>>     ...
> >>>  </class-descriptor>
> >>>
> >>>I presume that now I need a <class-descriptor/> for the RegisterForm
> >>>
> >>>
> >class.
> >
> >
> >>>Is this correct?
> >>>I looked at the Article example but I just can't get my one to work.
> >>>
> >>>My app still says that OJB cannot recognize RegisterForm class in
> >>>repository.
> >>>
> >>>What am I doing wrong and how can I go about doing this correctly.
> >>>
> >>>Thanks
> >>>
> >>>--Alen
> >>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>
> >>>
> >>>
> >>>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
> >
> >
>
> --
> Regards,
> Raymond Barlow
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>


Re: Extent. How to?

Posted by Raymond Barlow <rb...@raymanoz.com>.
Hi Alen,

I'm fairly new to OJB, but I'm pretty sure that you would have to define 
a class-descriptor for the RegisterForm class. Just try this for now to 
see if it fixes your problem: copy the entire User class descriptor into 
a new RegisterForm class descriptor and just change the relevant bits 
(ie. class="za.co.alen.struts.RegisterForm").

It is a pain, but I think OJB needs to know how to map each extent class 
individually. There has been some postings about using "this" to extend 
mappings, but I've not been able to get this to work successfully.

Just thinking about your problem a bit futher, how is OJB to 
differentiate between a User class and a RegisterForm class when 
searching for a class? ie. If RegisterForm is the same table and 
persistent fields as User, then how can OJB tell if it should be giving 
you a User class or a RegisterForm class? Maybe an alternative for you 
is to have RegisterForm contain an aggregated User class? This way you 
could search for User, then create your RegisterForm class passing the 
relevant User class. Just some ideas....

Regards,
Raymond Barlow

Alen Ribic wrote:

>Thanks Raymond for your reply.
>
>This is the thing. I am very lost.
>The User class descriptor in repository contains all my filed mappings to my
>User table in db.
>Now za.co.alen.struts.RegisterForm class mapping is a very good question.
>What would the za.co.alen.struts.RegisterForm class mapping contain? I don't
>need any RegisterForm class specific fields at all.
>I just need to indicate to OJB that it needs to something like cast
>RegisterForm instance to User and hence would need to map that to User class
>/ table mapping. (Remember that the instance I get is of
>za.co.alen.struts.RegisterForm)
>RegisterForm class does not have any real meaning for persistence besides
>the inherited fields from User bean.
>It basically just contains overridden validate(...) method used for
>server-side validation in my struts components.
>
>I hope this is making sense. :-)
>
>--Alen
>
>
>
>----- Original Message -----
>From: "Raymond Barlow" <rb...@raymanoz.com>
>To: "OJB Users List" <oj...@db.apache.org>
>Sent: Tuesday, June 03, 2003 10:45 AM
>Subject: Re: Extent. How to?
>
>
>  
>
>>Hi Alen
>>
>>I hate to ask the obvious, but you never know :)
>>Have you created a mapping for za.co.alen.struts.RegisterForm in your
>>repository_user.xml file??
>>
>>Regards,
>>Raymond Barlow
>>
>>Alen Ribic wrote:
>>
>>    
>>
>>>Hi again
>>>
>>>I have sent an email already and got a good reply, but now I have an
>>>      
>>>
>issue
>  
>
>>>with mapping side.
>>>
>>>I have got classes as follows:
>>>
>>>// JavaBean
>>>public class User extends ValidatorForm {}
>>>
>>>// Struts form bean
>>>public class RegisterForm extends User {}
>>>
>>>Now I just need OJB to recognize RegisteForm class as a User.
>>>
>>>usr = request.getAttribute("registerForm"); // returns RegisteForm
>>>      
>>>
>instance
>  
>
>>>broker.store(usr);
>>>
>>>So now, OJB on store(...) should look at mapping for User class to User
>>>table.
>>>
>>> <class-descriptor
>>>     class="za.co.alen.jfaq.User"
>>>     table="User"
>>>  >
>>>     <extent-class class-ref="za.co.alen.struts.RegisterForm" />
>>>     <!-- field mappings -->
>>>     ...
>>>  </class-descriptor>
>>>
>>>I presume that now I need a <class-descriptor/> for the RegisterForm
>>>      
>>>
>class.
>  
>
>>>Is this correct?
>>>I looked at the Article example but I just can't get my one to work.
>>>
>>>My app still says that OJB cannot recognize RegisterForm class in
>>>repository.
>>>
>>>What am I doing wrong and how can I go about doing this correctly.
>>>
>>>Thanks
>>>
>>>--Alen
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>      
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>  
>

-- 
Regards,
Raymond Barlow



Re: Extent. How to?

Posted by Alen Ribic <al...@mweb.co.za>.
Thanks Raymond for your reply.

This is the thing. I am very lost.
The User class descriptor in repository contains all my filed mappings to my
User table in db.
Now za.co.alen.struts.RegisterForm class mapping is a very good question.
What would the za.co.alen.struts.RegisterForm class mapping contain? I don't
need any RegisterForm class specific fields at all.
I just need to indicate to OJB that it needs to something like cast
RegisterForm instance to User and hence would need to map that to User class
/ table mapping. (Remember that the instance I get is of
za.co.alen.struts.RegisterForm)
RegisterForm class does not have any real meaning for persistence besides
the inherited fields from User bean.
It basically just contains overridden validate(...) method used for
server-side validation in my struts components.

I hope this is making sense. :-)

--Alen



----- Original Message -----
From: "Raymond Barlow" <rb...@raymanoz.com>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Tuesday, June 03, 2003 10:45 AM
Subject: Re: Extent. How to?


> Hi Alen
>
> I hate to ask the obvious, but you never know :)
> Have you created a mapping for za.co.alen.struts.RegisterForm in your
> repository_user.xml file??
>
> Regards,
> Raymond Barlow
>
> Alen Ribic wrote:
>
> >Hi again
> >
> >I have sent an email already and got a good reply, but now I have an
issue
> >with mapping side.
> >
> >I have got classes as follows:
> >
> >// JavaBean
> >public class User extends ValidatorForm {}
> >
> >// Struts form bean
> >public class RegisterForm extends User {}
> >
> >Now I just need OJB to recognize RegisteForm class as a User.
> >
> >usr = request.getAttribute("registerForm"); // returns RegisteForm
instance
> >broker.store(usr);
> >
> >So now, OJB on store(...) should look at mapping for User class to User
> >table.
> >
> >  <class-descriptor
> >      class="za.co.alen.jfaq.User"
> >      table="User"
> >   >
> >      <extent-class class-ref="za.co.alen.struts.RegisterForm" />
> >      <!-- field mappings -->
> >      ...
> >   </class-descriptor>
> >
> >I presume that now I need a <class-descriptor/> for the RegisterForm
class.
> >Is this correct?
> >I looked at the Article example but I just can't get my one to work.
> >
> >My app still says that OJB cannot recognize RegisterForm class in
> >repository.
> >
> >What am I doing wrong and how can I go about doing this correctly.
> >
> >Thanks
> >
> >--Alen
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>


Re: Extent. How to?

Posted by Raymond Barlow <rb...@raymanoz.com>.
Hi Alen

I hate to ask the obvious, but you never know :)
Have you created a mapping for za.co.alen.struts.RegisterForm in your 
repository_user.xml file??

Regards,
Raymond Barlow

Alen Ribic wrote:

>Hi again
>
>I have sent an email already and got a good reply, but now I have an issue
>with mapping side.
>
>I have got classes as follows:
>
>// JavaBean
>public class User extends ValidatorForm {}
>
>// Struts form bean
>public class RegisterForm extends User {}
>
>Now I just need OJB to recognize RegisteForm class as a User.
>
>usr = request.getAttribute("registerForm"); // returns RegisteForm instance
>broker.store(usr);
>
>So now, OJB on store(...) should look at mapping for User class to User
>table.
>
>  <class-descriptor
>      class="za.co.alen.jfaq.User"
>      table="User"
>   >
>      <extent-class class-ref="za.co.alen.struts.RegisterForm" />
>      <!-- field mappings -->
>      ...
>   </class-descriptor>
>
>I presume that now I need a <class-descriptor/> for the RegisterForm class.
>Is this correct?
>I looked at the Article example but I just can't get my one to work.
>
>My app still says that OJB cannot recognize RegisterForm class in
>repository.
>
>What am I doing wrong and how can I go about doing this correctly.
>
>Thanks
>
>--Alen
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>  
>



Re: Extent. How to?

Posted by Raymond Barlow <rb...@raymanoz.com>.
Sorry, just reread your email.

Yes, you do need to define a mapping ( a class-descriptor) for the 
RegisterForm class.

Regrads,
Raymond Barlow

Alen Ribic wrote:

>Hi again
>
>I have sent an email already and got a good reply, but now I have an issue
>with mapping side.
>
>I have got classes as follows:
>
>// JavaBean
>public class User extends ValidatorForm {}
>
>// Struts form bean
>public class RegisterForm extends User {}
>
>Now I just need OJB to recognize RegisteForm class as a User.
>
>usr = request.getAttribute("registerForm"); // returns RegisteForm instance
>broker.store(usr);
>
>So now, OJB on store(...) should look at mapping for User class to User
>table.
>
>  <class-descriptor
>      class="za.co.alen.jfaq.User"
>      table="User"
>   >
>      <extent-class class-ref="za.co.alen.struts.RegisterForm" />
>      <!-- field mappings -->
>      ...
>   </class-descriptor>
>
>I presume that now I need a <class-descriptor/> for the RegisterForm class.
>Is this correct?
>I looked at the Article example but I just can't get my one to work.
>
>My app still says that OJB cannot recognize RegisterForm class in
>repository.
>
>What am I doing wrong and how can I go about doing this correctly.
>
>Thanks
>
>--Alen
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>  
>

-- 
Regards,
Raymond Barlow