如何使用Dozer和注释正确映射地图
没有列表,一切运作良好
推土机版本6.1.0
http://dozer.sourceforge.net/documentation/collectionandarraymapping.html 如何在注释上呈现b-hint
@Entity
@Table(name = "PRODUCT_THEME")
@Data
public class ProductTheme implements Serializable {
@Id
@GeneratedValue(generator = "PRODUCT_THEME_SEQ", strategy = GenerationType.SEQUENCE)
@SequenceGenerator(name = "PRODUCT_THEME_SEQ", sequenceName = "PRODUCT_THEME_SEQ", allocationSize = 1)
@Column(name = "ID", updatable = false, nullable = false)
@Mapping("id")
private Integer id;
@Column(name = "DESCRIPTION", length = 100)
@Mapping("description")
private String description;
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "PRODUCT_THEME_IMAGE", joinColumns = { @JoinColumn(name = "THEME_ID", nullable = false, updatable = false) }, inverseJoinColumns = {
@JoinColumn(name = "IMAGE_ID", nullable = false, updatable = false) })
**@Mapping("imagesList")**
private List<Images> imagesList;
@Column(name = "ACTIVE", nullable = false)
@Mapping("active")
private Boolean active;
...
}
一切正常,但当我尝试获取地图列表时,我收到错误
如何在不配置xml的情况下解决此问题?
Caused by: java.lang.StackOverflowError
at java.util.AbstractCollection.toString(AbstractCollection.java:454)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.Images.toString(Images.java:15)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.ProductTheme.toString(ProductTheme.java:21)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.Images.toString(Images.java:15)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.ProductTheme.toString(ProductTheme.java:21)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.Images.toString(Images.java:15)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.ProductTheme.toString(ProductTheme.java:21)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.Images.toString(Images.java:15)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.ProductTheme.toString(ProductTheme.java:21)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.Images.toString(Images.java:15)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.ProductTheme.toString(ProductTheme.java:21)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.util.AbstractCollection.toString(AbstractCollection.java:462)
at java.util.Vector.toString(Vector.java:1000)
at org.eclipse.persistence.indirection.IndirectList.toString(IndirectList.java:890)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at by.softclub.model.entity.Images.toString(Images.java:15)
答案 0 :(得分:0)
错误来自Lomdok和Dozer的сompatibility@Date(@toString)
答案 1 :(得分:0)
为防止lombok的ToString()
以递归方式运行,应排除链接字段。 hashCode()
:
@Entity
@Table(name = "PRODUCT_THEME")
@Data
@lombok.ToString(exclude="imagesList")
@lombok.EqualsAndHashCode(exclude="imagesList")
public class ProductTheme implements Serializable {
...
}