[seasar-user-en:23] Re: Mapping with S2dao.
Yasuo Higa
[E-MAIL ADDRESS DELETED]
Thu Apr 13 17:04:21 JST 2006
Hi,
> Can we map with S2dao like one-to-many.
>
Sorry, S2Dao don't support one-to-many mapping.
However you can do as follows:
public interface XYZDao {
Class BEAN = XYZ.class;
public XYZ getXYZ(String code);
public ...
}
public abstract class XYZDaoImpl implements XYZDao {
private PQRDao pqrDao;
...
public XYZ getXYZ(String code) {
XYZ xyz = super.getXYZ(code);
Set pqrs = pqrDao.getPQRs(code);
xyz.setPQRs(pqrs);
pqrs.setXYZ(xyz);
return xyz;
}
}
>
> I want to use "values" of entity class XYZ will have a map to another entity
> class PQR.
> and this will be a one-to-many Map.
>
>
> public class XYZ {
>
> private static final String TABLE="Z_XYZ";
> //ID
> private String code = null;
> /** Values which belong to this definition */
> private Set values = Collections.EMPTY_SET;
> }
>
> public class PQR {
>
> private static final String TABLE="Z_PQR";
>
> /** [PK]ID */
> private Long id = null;
>
> /** XYZ */
> private XYZ definition = null;
> }
Yasuo Higa
The Seasar Foundation
More information about the seasar-user-en
mailing list