Hi folks,
I need help for I get an karthesian product of data. The database structure is defined as:
ER-Diagramm
Code:
+---+ +---+
| A |+--<| B |
+---+ +---+
The result I would expect by the mapping below is for i.e. 4 searchvalues:
a1->b1, b2, b3
a2->b4, b5
a3-><empty>
a4->b1, b2, b3
What I get is:
a1->b1, b2, b3
a1->b1, b2, b3
a1->b1, b2, b3
a2->b4, b5
a2->b4, b5
a3-><empty>
a4->b1, b2, b3
a4->b1, b2, b3
a4->b1, b2, b3The mapping ...
to gather gather data from the given ER. But only
unidirectional for
there is no need to find the valu of A from an Instance of B.
Code:
@Entity
public class A implements IofA {
@Id
private Long key1;
privtae Long searchValue;
@OneToMany(mappedBy = "key1", fetch = FetchType.EAGER)
private List<B> finance;
// further members, getter and setter
}
Code:
@Entity
@IdClass(value = B_PK.class)
public class B implements IofB {
/**
* part of the primary key.
* This value is the same an the PK of class A
*/
@Id
private Double key1;
@Id
private Short key2;
@Id
private Character key3;
// further member, getter and setter ...
}
Code:
/**
* definition of the composed PK of class B
*/
@Embeddable
public class B_PK implements Serializable {
@Id
private Double key1;
@Id
private Short key2;
@Id
private Character key3;
// getter and setter named exactly the same as in B
}
The repository ...Code:
/**
* The repository to gather data:
*/
public class Hibernate3_RiskRepository {
public List<IofA> findData(List<Long> searchvalues) {
LOG.debug("Filtered searchValues's are: " + searchvalues);
Criterion criterion = Restrictions.in("searchValue", searchvalues);
List<IofA> list = super.findByCriteria(criterion, (Order[]) null);
return list;
}
}
Any idea?