Hi
all,
I have a problem
with my mapping and would really like some help. I have worked with castor for
some time and I have never seen the problem before.
Its when I do a OQL
like "Select p from com.frovi.vmi.entities.impl.simple.ProductImpl p". If I
remove the grades-relationship I get a neat list of objects
exactly like I
want them. It's when the join with the grades-table are there I get some
duplicates. In the castor-debug it says it's loading the correct number of
products but the in the code I use I get more results that that.
while
(results.hasMore())
{
ProductImpl
product= (ProductImpl)results.next();
System.out.println("adding:"
+ product.getId());
resultList.add(product);
}
I normally don't
use Strings as identifyers but as the system
I'm
integrating with are I have to and I suspect that might have something
to do with it.
Here it
is:
<!-- Mapping for Product -->
<class
name="com.frovi.vmi.entities.impl.simple.ProductImpl"
identity="productCode">
<description>Product</description>
<map-to table="product"/>
<field name="id" type="java.lang.Integer"
dirty="check" >
<sql name="productId"
type="integer"/>
</field>
<field name="name"
type="java.lang.String">
<sql name="prodCode" type="varchar"
dirty="check" />
</field>
<field name="grades"
type="com.frovi.vmi.entities.impl.simple.GradeImpl" collection="collection"
lazy="false">
<sql many-key="prodCode" />
</field>
<field name="productCode"
type="java.lang.String">
<sql name="prodCode" type="varchar"
/>
</field>
</class>
<!-- Mapping for Grade -->
<class
name="com.frovi.vmi.entities.impl.simple.GradeImpl"
identity="gradeCode">
<description>Grade</description>
<map-to table="grade"/>
<field name="id" type="java.lang.Integer"
dirty="check" >
<sql name="gradeId"
type="integer"/>
</field>
<field name="product"
type="com.frovi.vmi.entities.impl.simple.ProductImpl">
<sql name="prodCode" />
</field>
<field name="name"
type="java.lang.String">
<sql name="name" type="varchar" dirty="check"
/>
</field>
<field name="gradeCode"
type="java.lang.String">
<sql name="gradCode" type="varchar"
/>
</field>
</class>
Regards
Mattias
Bogeblad
_______________________________________________________________
Mattias Bogeblad | PH: +46 31
799 01 16 | MOB: +46 702 80 05 05
SPRAWL SOLUTIONS AB
FABRIKSGATAN
7
412 50
G�TEBORG
FAX: +46 31 799 00 10
_______________________________________________________________
