It sounds like your over thinking this.  I don't think you need *any*
extents.  You never query for anything but your concrete class, so only
map the RegisterForm and LogonForm.

BTW...why would you want to persist a struts form-bean anyways?

Wallace J Gelhar
Facilities Planning & Management
Computer Information Systems
[EMAIL PROTECTED]
(715) 836-3411


-----Original Message-----
From: Thomas Mahler [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 03, 2003 11:19 AM
To: OJB Users List
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 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" <[EMAIL PROTECTED]>
> To: "OJB Users List" <[EMAIL PROTECTED]>
> 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" <[EMAIL PROTECTED]>
>>>To: "OJB Users List" <[EMAIL PROTECTED]>
>>>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: [EMAIL PROTECTED]
>>>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>--------------------------------------------------------------------
>>>>-
>>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to