So my way of using reference proxies is:
1) Let's consider two business entities: state and city. So I have:
public interface StateProxy
{
public Integer getCodState();
public String getDescState();
public Collection getCities();public void setCodState(Integer state); public void setDescState(String description); public void setCities(Collection cities); }
public class StateVO implements StateProxy, Serializable
{
private Integer codState;
private String descState;private Collection cities;
public StateVO()
{
}// Getters/Setters .... }
public interface CityProxy
{
public Integer getCodCity();
public String getDescCity();
public StateProxy getState();public void setCodCity(Integer city); public void setDescCity(String description); public void setState(StateProxy state); }
public class CityVO implements CityProxy, Serializable
{
private Integer codCity;
private String descCity;private StateProxy state;
public CityVO()
{
state = new StateVO();
}// Getters/Setters .... }
2) Do the mapping in repository-user.xml:
<class-descriptor class="StateVO" table="TBL_STATE"
<field-descriptor id="1" name="codState" column="ID_STATE" jdbc-type="INTEGER" primarykey="true" />
<field-descriptor
id="2"
name="descState"
column="DESC_STATE"
jdbc-type="VARCHAR" /> <collection-descriptor
name="cities"
element-class-ref="CityVO"
proxy="true"><inverse-foreignkey field-id-ref="3" />
</collection-descriptor>
</class-descriptor>
<class-descriptor class="CityVO" table="TBL_CITY"
<field-descriptor id="1" name="codCity" column="ID_CITY" jdbc-type="INTEGER" primarykey="true" />
<field-descriptor
id="2"
name="descCity"
column="DESC_CITY"
jdbc-type="VARCHAR" /> <field-descriptor
id="3"
name="state::codState"
column="ID_STATE"
jdbc-type="INTEGER" /> <reference-descriptor
name="state"
class-ref="StateVO"
proxy="true"><foreignkey field-id-ref="3" />
</reference-descriptor>
</class-descriptor>
And my questions are the following:
a) I declare the variable 'state' in class 'CityVO' as being of type 'StateProxy' (the interface). If not, I get errors from OJB indicating it can't obtain a getter/setter for the 'Proxy' object (I suppose it tries to obtain a getter/setter for the interface, not for the implementacion class). Is this the right behaviour?
b) I have to instantiate the variable 'state' in class 'CityVO' inside the default constructor, because if not, OJB throws an exception saying it cannot instantiate 'StateProxy'. I suppose this must be correct.
c) With the collection variable 'cities' in class 'StateVO', there's no need to instantiate it on the constructor, as OJB knows how to instantiate any collection. Am I right?
d) Do you think is correct to map the 'foreign key' using the variable 'state' defined in class 'CityVO' in the way 'state::codState' in the class-descriptor for 'CityVO'?
I would welcome any suggestions, critics and comments from anyone that has worked with reference proxies and interfaces with OJB.
Thanks in advance, Enrique Medina.
_________________________________________________________________
�D�nde se esconden [EMAIL PROTECTED] [EMAIL PROTECTED] Encuentra miles de perfiles en MSN Amor & Amistad. http://match.msn.es/
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
