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 "ludovic.bert" <lu...@voila.fr> on 2003/08/06 16:19:42 UTC
How to use the attribute tag?
Hello all!
I'm using OJB, and want to load all InventaireTable of a TransportFiche where the InventaireTable.typeVisiteDossier=2
to do this I use the attribute tag using : <attribute attribute-name="typeVisiteDossier" attribute-value="2"/>. But OJB load all
InventaireTable of the TransportFiche including typeVisiteDossier=1. I think the repository.xml is bad configured or the attribute
tag was created to do this. I don't know what is wrong. Could someone help me please.
Fragment of the repository.xml:
<!-- Definitions for com.mps.safari.gestion.TransportFiche -->
<class-descriptor class="com.mps.safari.gestion.TransportFiche" table="trajet">
<field-descriptor id="1" name="id" column="TRAJET_ID" jdbc-type="BIGINT" primarykey="true" autoincrement="true"/>
...
<collection-descriptor name="inventaires" element-class-ref="com.mps.safari.gestion.InventaireTable">
<inverse-foreignkey field-ref="codeVisiteDossier"/>
<attribute attribute-name="typeVisiteDossier" attribute-value="2"/>
</collection-descriptor>
</class-descriptor>
<!-- Definitions for com.mps.safari.gestion.InventaireTable -->
<class-descriptor class="com.mps.safari.gestion.InventaireTable" table="inventaire">
<field-descriptor id="1" name="id" column="INVENTAIRE_ID" jdbc-type="BIGINT" primarykey="true" autoincrement="true"/>
...
<field-descriptor id="3" name="typeVisiteDossier" column="TYPE_VISITE_DOSSIER" jdbc-type="INTEGER"/>
<field-descriptor id="4" name="codeVisiteDossier" column="CODE_VISITE_DOSSIER" jdbc-type="BIGINT"/>
...
</class-descriptor>
------------------------------------------
Faites un voeu et puis Voila ! www.voila.fr
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: How to use the attribute tag?
Posted by Thomas Cornet <th...@cornet.name>.
Attributes only work with a query customizer. A query customizer implements
interface org.apache.ojb.broker.accesslayer.QueryCustomizer and allows you
to modify the way the collections is created.
Your repository.xml should look like this :
<collection-descriptor
name="liste"
...
>
<inverse-foreignkey field-ref="..."/>
<query-customizer class="package.YourQueryCustomizer">
<attribute attribute-name="<paramName>"
attribute-value="<paramValue>" />
</query-customizer>
</collection-descriptor>
For a little miore info, see the bottom of page '/doc/tutorial3.html'.
Thomas
At 16:19 06/08/2003, you wrote:
>Hello all!
>
>I'm using OJB, and want to load all InventaireTable of a TransportFiche
>where the InventaireTable.typeVisiteDossier=2
>to do this I use the attribute tag using : <attribute
>attribute-name="typeVisiteDossier" attribute-value="2"/>. But OJB load all
>InventaireTable of the TransportFiche including typeVisiteDossier=1. I
>think the repository.xml is bad configured or the attribute
>tag was created to do this. I don't know what is wrong. Could someone help
>me please.
>
>Fragment of the repository.xml:
>
><!-- Definitions for com.mps.safari.gestion.TransportFiche -->
><class-descriptor class="com.mps.safari.gestion.TransportFiche"
>table="trajet">
> <field-descriptor id="1" name="id" column="TRAJET_ID"
> jdbc-type="BIGINT" primarykey="true" autoincrement="true"/>
> ...
> <collection-descriptor name="inventaires"
> element-class-ref="com.mps.safari.gestion.InventaireTable">
> <inverse-foreignkey field-ref="codeVisiteDossier"/>
> <attribute attribute-name="typeVisiteDossier" attribute-value="2"/>
> </collection-descriptor>
></class-descriptor>
>
><!-- Definitions for com.mps.safari.gestion.InventaireTable -->
><class-descriptor class="com.mps.safari.gestion.InventaireTable"
>table="inventaire">
> <field-descriptor id="1" name="id" column="INVENTAIRE_ID"
> jdbc-type="BIGINT" primarykey="true" autoincrement="true"/>
> ...
> <field-descriptor id="3" name="typeVisiteDossier"
> column="TYPE_VISITE_DOSSIER" jdbc-type="INTEGER"/>
> <field-descriptor id="4" name="codeVisiteDossier"
> column="CODE_VISITE_DOSSIER" jdbc-type="BIGINT"/>
> ...
> </class-descriptor>
>
>------------------------------------------
>
>Faites un voeu et puis Voila ! www.voila.fr
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org