I have two hibernate entities:
@Entity
@Table(name = DBConstants.TABLE_PARTNER)
public class Partner extends XWeedEntity {
private static final long serialVersionUID = 5692151244956513381L;
@Id
@Column(name = DBConstants.PARTNER_COL_PARTNER_NUMBER)
private Integer partnerNumber;
@OneToMany(mappedBy = DBConstants.VISIT_PROP_VISITOR)
private List<Visit> visits;
// More fields and properties...
}
@Entity
@Table(name = DBConstants.TABLE_VISIT)
public class Visit extends XWeedEntity {
private static final long serialVersionUID = -8324746049334117579L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = DBConstants.VISIT_COL_ID)
private Integer id;
@ManyToOne
@JoinColumn(name = DBConstants.VISIT_COL_VISITOR, nullable = false)
private Partner visitor;
// More fields and properties...
}
And two DTO entities:
public class PartnerDto extends XWeedEntity {
private static final long serialVersionUID = 5692151244956513381L;
private Integer partnerNumber;
private List<VisitDto> visits;
// More fields and properties...
}
public class VisitDto extends XWeedEntity {
private static final long serialVersionUID = -8324746049334117579L;
private Integer id;
private PartnerDto visitor;
// More fields and properties...
}
And I've got the following dozer mappings:
<mapping map-id="partnerWithCollections" map-empty-string="false" map-null="false">
<class-a>org.xweed.model.app.domain.dbo.Partner</class-a>
<class-b>org.xweed.model.app.domain.dto.PartnerDto</class-b>
<field map-id="visitWithPartner">
<a>visits</a>
<b>visits</b>
</field>
</mapping>
<mapping map-id="partnerBasic" wildcard="false" map-empty-string="false" map-null="false">
<class-a>org.xweed.model.app.domain.dbo.Partner</class-a>
<class-b>org.xweed.model.app.domain.dto.PartnerDto</class-b>
<field>
<a>partnerNumber</a>
<b>partnerNumber</b>
</field>
</mapping>
<mapping map-id="visitWithPartner" map-empty-string="false" map-null="false">
<class-a>org.xweed.model.app.domain.dbo.Visit</class-a>
<class-b>org.xweed.model.app.domain.dto.VisitDto</class-b>
<field map-id="partnerBasic">
<a>visitor</a>
<b>visitor</b>
</field>
</mapping>
The problem is that when I call dozer using "partnerWithCollections" mapping, dozer is mapping all Visit objects from the Partner visits, but every single visit has it's visitor with it's visits collection and so on, when the visitor attribute of each visit should only contain the partnerNumber.
If I try to exclude visitor field from visit, then works, and each visitor's visit is null, but for some reason it is not working using map-id to use some concrete Partner mapping.
Any ideas?
Thanks in advance.