0
我有twi实体。分类实体:JAXB:在对象图中检测到周期
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@Entity
@Table(name = "EPBS_DATA.NEWS_CATEGORY")
@XmlType(propOrder = { "id", "name", "news" })
public class CategoryEntity {
public final static String ID_GENERATOR_NAME =
"EPBS_DATA.sq_news_category";
@Id
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = ID_GENERATOR_NAME)
@SequenceGenerator(name = ID_GENERATOR_NAME,
sequenceName = ID_GENERATOR_NAME, allocationSize = 1)
private long id;
@Column(name = "CATEGORY_NAME", nullable = false, length = 1024)
private String name;
@ManyToMany(mappedBy = "categories")
@XmlElementWrapper(name = "news")
@XmlElement(name = "")
private List<NewsEntity> news = new ArrayList<NewsEntity>();
setters/getters
}
和NewsEntity
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@Entity
@Table(name = "EPBS_DATA.NEWS")
@XmlType(propOrder =
{ "id", "body", "lead", "creatorId", "date", "federal", "regId",
"raw", "file", "title", "editDate", "fixed", "categories",
"publishDates" })
public class NewsEntity {
public final static String ID_GENERATOR_NAME = "EPBS_DATA.SQ_EPBS";
public final static String GET_NEWS_BY_DATE = "NewsEntity.getNewsByDate";
public final static String GET_NEWS_COUNT = "NewsEntity.getNewsCount";
public final static String GET_DATES = "NewsEntity.getDates";
@Id
@Column(name = "NEWS_ID", nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = ID_GENERATOR_NAME)
@SequenceGenerator(name = ID_GENERATOR_NAME,
sequenceName = ID_GENERATOR_NAME, allocationSize = 1)
private long id;
@Column(name = "NEWS_BODY", nullable = true)
@Lob
private String body;
@ManyToMany
@JoinTable(name = "EPBS_DATA.NEWS_CATEGORY_ASSIGMENT",
joinColumns = @JoinColumn(name = "ID_NEWS",
referencedColumnName = "NEWS_ID"),
inverseJoinColumns =
@JoinColumn(name = "ID_CATEGORY", referencedColumnName = "ID"))
@XmlInverseReference(mappedBy = "news")
@XmlElementWrapper(name = "categories")
@XmlElement(name = "")
private List<CategoryEntity> categories = new ArrayList<CategoryEntity>();
我有误差的循环对象图中检测到。这将导致无限深XML:[email protected] - > [email protected] - > [email protected]]
我尝试使用@XmlTransient和@XmlInverseReference,但无论我有错误。
尚未此数据 - [email protected]引用自身?你的数据是什么? – farrellmr
在你的对象图中的周期无关的JPA API,因为任何JPA提供商可以与这样的事情处理。这只是XML。所以删除JPA标签 –