[ojb-users] references
Brought to you by:
thma
From: Ebersole, S. <ste...@vi...> - 2002-05-02 13:53:55
|
I am looking at switching from Castor over to OJB as it looks really promising in terms of its functionality (I especially love the use of virtual proxies here). I did have two questions come up from my initial trials of OJB. 1) Is it necessary to have both the foreign key and the foreign reference mapped and present on the object? In the examples, the relation between Article and ProductGroup is the example From which I was working. There, Article has two attributes dealing with its relation to a ProductGroup, productGroupId (which is the DB fk field) and productGroup (which is an instance of the ProductGroup object to which productGroupId referes). Is it necessary to do this, or is there a way to have the Product object only know about its related ProductGroup? 2) I mapped a relationship, uing my classes, similiar to the above relationship (it is a company -> parent company relationship). However, I get exceptions if a particular company did not have a parent company (its PRTN_COMP_ID column on the DB is NULL). Is there something additional I have to set up in the mapping to define that side of the relationship as optional? Below is the mapping I have for this: <ClassDescriptor id="2"> <class.name>com.vignette.it.apps.dbapi.domain.CompanyDO</class.name> <table.name>COMPANY</table.name> <FieldDescriptor id="1"> <field.name>id</field.name> <column.name>COMP_ID</column.name> <jdbc_type>INTEGER</jdbc_type> <PrimaryKey>true</PrimaryKey> </FieldDescriptor> ... <FieldDescriptor id="5"> <field.name>parentCompanyId</field.name> <column.name>PRNT_COMP_ID</column.name> <jdbc_type>INTEGER</jdbc_type> </FieldDescriptor> <ReferenceDescriptor id="1"> <rdfield.name>parentCompany</rdfield.name> <referenced.class>com.vignette.it.apps.dbapi.domain.CompanyDO</referenced.cl ass> <fk_descriptor_ids>5</fk_descriptor_ids> </ReferenceDescriptor> </ClassDescriptor> Thanks ******************************************** Steve Ebersole IT Integration Engineer Vignette Corporation 512.741.4195 Visit http://www.vignette.com ******************************************** |