我在涉及映射对象的问题上遇到了问题。 这是使用的实体:
@Entity
@Table(name = "skill")
public class Skill {
.
.
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "collab_id")
private Collaborateur collaborateur;
........................
@Entity
@Table(name = "collaborateur")
public class Collaborateur {
.
.
@OneToOne(fetch = FetchType.LAZY, mappedBy = "collaborateur")
private Skill skill;
我的jsp文件:
<form:form action="/app/skill" method="post" modelAttribute="skill"
id="myForm">
<div>
<fieldset>
<legend>Recherche de skill par critere :</legend>
.
.
.
<form:select path="collaborateur" id="input" >
<form:option value="" label="--Collaborateur--"></form:option>
<form:options path="collaborateur" items="${collaborateurs}" itemLabel="firstname" itemValue="id"/>
</form:select>
<input type="submit" value="Search" name="Search"
class="searchButton" onclick="pagination('${1}', '${size}')" />
</fieldset>
当我尝试搜索&#34; collaborateur&#34;在&#34;技能&#34;列表,使用弹簧数据中的示例,我得到了这个错误。
org.springframework.dao.InvalidDataAccessApiUsageException: Path
'collaborateur.skill.collaborateur' from root Skill must not span a cyclic
property reference!
[{ com.app.entities.Skill@a648b00 }] -collaborateur-> [{
com.app.entities.Collaborateur@2b }] -skill-> [{
com.app.entities.Skill@33a1c699 }] -collaborateur-> [{
com.app.entities.Collaborateur@2b }]
导致此错误的原因是什么?