Hi. I would need to stablish a 1 to many relation but the foreing key have a
different name than the PK in the parent table. I have a relation
stablished in mapping, but Castor generates a query using the PK name
for the FK... and it is wrong.

this is the generated query:
SELECT
"preciosmf"."id","preciosmf"."idproducto","preciosmf"."fecha","detalleprecio
smf"."id" FROM "preciosmf" LEFT OUTER JOIN "detallepreciosmf" ON
"preciosmf"."id"="detallepreciosmf"."id"

it should be:
<SELECT
"preciosmf"."id","preciosmf"."idproducto","preciosmf"."fecha","detalleprecio
smf"."id" FROM "preciosmf" LEFT OUTER JOIN "detallepreciosmf" ON
"preciosmf"."id"="detallepreciosmf"."idpreciomf">



This is an extract from my mapping.xml

  <!--  Mapping for com.roagro.producto.PrecioMF  -->
  <class name="com.roagro.producto.PrecioMF"  identity="id"
key-generator="preciosmf">
    <description>Producto y fecha de la cual se registran precios
mf</description>
    <map-to table="preciosmf" />

    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>

    <!-- Un precio mercado fisico hace referencia a un producto -->
    <field name="producto" type="com.roagro.producto.Producto">
      <sql name="idproducto" />
        </field>

    <field name="fecha" type="date">
      <sql name="fecha" type="date" />
    </field>

    <!-- Un producto en una fecha hace  referencia a 2 periodos y sus
precios-->
    <field name="detalle" type="com.roagro.producto.DetallePrecioMF"
collection="vector" required="true">
        <sql many-key="idpreciomf"/>
    </field>

  </class>

  <!--  Mapping for com.roagro.producto.DetallePrecioMF  -->
  <class name="com.roagro.producto.DetallePrecioMF"  identity="id"
key-generator="detallepreciosmf">
    <description>Definici�n del detalle de precios MF</description>
    <map-to table="detallepreciosmf" />

        <field name="id" type="integer">
        <sql name="id" type="integer" />
        </field>

    <field name="periodo" type="string">
        <sql name="periodo" type="varchar" />
    </field>
    <field name="estimado" type="string">
      <sql name="estimado" type="varchar" />
    </field>
    <field name="negociado" type="string">
      <sql name="negociado" type="varchar" />
    </field>


    <field name="tipos" type="com.roagro.producto.TipoPrecioMF"
collection="vector">

    </field>

   </class>


If you need more information, ask me for it, please.

Thanks for any help.
Regards.


Ing. Mar�a Laura Vel�zquez
Desarrollo de Sistemas
(54) 341 4470420
www.spcom.com.ar

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to