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 Hao Chen <ch...@hotmail.com> on 2002/12/20 23:21:14 UTC

Component Mapping?

Hi,

I am new to OJB. I wonder if OJB has something like Hibernate's component 
mapping, which makes code structure better and reuse easier.

Thanks.
=============================================

Re: Component Mapping?

Posted by Thomas Mahler <th...@apache.org>.
Yes that's possible with OJB too!
You have to tell OJB to use a PersistenField implementation supporting 
this in OJB.properties first, as it is not yet implemented in the 
default implementation:

PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentNestedFieldMaxPerformanceImpl

if your class has an attribute "address" of type Adress,
the mapping for the "street" attribute of "address" would look like follows:

       <field-descriptor id="10"
          name="adress->street"
          column="ADR_STREET"
          jdbc-type="VARCHAR"
       />

cheers,
Thomas

Hao Chen wrote:
> Hi,
> 
> I am new to OJB. I wonder if OJB has something like Hibernate's 
> component mapping, which makes code structure better and reuse easier.
> 
> Thanks.
> =============================================
> 
>> From Hibernate Doc:
> 
> 
> Write fine-grained classes and map them using <component> or 
> <component-element>.
> Use an Address class to encapsulate street, suburb, state, postcode. 
> This encourages code reuse and simplifies refactoring.
> 
> component
> The <component> element maps properties of a child object to columns of 
> the table of a parent class. Components may, in turn, declare their own 
> properties, components or collections. See "Components" below.
> 
> <component name="propertyName" class="className"/>
>        <property ...../>
>        ........
> </component>
> name: The name of the property.
> 
> class (optional - defaults to the property type determined by 
> reflection): The name of the component (child) class.
> 
> The child <property> tags map properties of the child class to table 
> columns.
> 
> 
> 
> _________________________________________________________________
> STOP MORE SPAM with the new MSN 8 and get 3 months FREE*. 
> http://join.msn.com/?page=features/junkmail&xAPID=42&PS=47575&PI=7324&DI=7474&SU= 
> http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_stopmorespam_3mf 
> 
> 
> 
> -- 
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 
>