Bu soruyla ilgili Spring Data Rest Ambiguous Association Exception numaralı telefonu ziyaret ettim, ancak bu dosya benim işim için işe yaramadı.Spring Data Rest: Aynı ilişkiye sahip birden fazla ilişkilendirme bağlantısı tespit edildi.
Aşağıdaki kodumda gördüğünüz gibi, ek notunu rel
diğer bir değere eşit olarak ekledim. Yukarıdaki soruya benzer
, POST istekleri çalışır, ancak istekleri aynı ilişki türü ile birden dernek bağlantıları hakkında istisna GET: Aynı ilişki türüyle Tespit birden dernek bağlantıları:
"JSON yazılamadı ! org.springframework.data.rest.core.annotation.RestResource @ ilişki disambiguate (gör = CreatedBy, ihraç = doğru mu, yol =, [email protected]iption (değer =)) @ javax.persistence.ManyToOne (isteğe bağlı = true, targetEntity = void, kaskat = [], getirme = EAGER) javax.persistence.JoinColumn @ (referencedColumnName = ASSIGNABLE_ID, olabilecek = kapalı, tek = kapalı, adı = CREATED_BY, = güncelleştirilebilir doğru, columnDefinition = [email protected] (ad = value = CONSTRAINT, foreignKeyDefinition =), tablo =, insertable = true) private com.ag.persistence.domain.PersonEntity com.ag.persistence.domain.TeamEntity.createdBir @RestResource! (başvuru zinciri aracılığıyla: org.springframework.hateoas.PagedResources [\ "_ katıştırılmış \"] -> java.util.UnmodifiableMap [\ "kişiler \"] -> java.util.ArrayList [0]); iç içe istisna com.fasterxml.jackson.databind.JsonMappingException: Aynı ilişki türüyle birden çok ilişkilendirme bağlantısı tespit edildi! Disambiguate association @ org.springframework.data.rest.core.annotation.RestResource (rel = oluşturulanBy, dışa aktarılan = true, yol =, [email protected]iption (value =)) javax.persistence.ManyToOne @ (= isteğe bağlı doğru, targetEntity = boşluk, kademeli = []), javax.persistence.JoinColumn @ = EAGER getirme (referencedColumnName = ASSIGNABLE_ID, olabilecek = kapalı, tek = kapalı, adı = CREATED_BY, updatable = true, columnDefinition =, [email protected] (name = value = CONSTRAINT, foreignKeyDefinition =), tablo =, yerleştirilebilir = true) private com.ag.persistence.domain.PersonEntity com.ag.persistence.domain.TeamEntity.createdBy u @RestResource şarkısını söylendi! (referans zinciri üzerinden: org.springframework.hateoas.PagedResources [\ "_ gömülü \"] -> java.util.UnmodifiableMap [\ "kişi \"] -> java.util.ArrayList [0])"
hata bu sınıfta oluyor gibi görünüyor.
@Entity
@Table(name = "team")
public class TeamEntity extends AssignableEntity {
private String name;
private LocalDateTime createdDate;
private LocalDateTime modifiedDate;
private Collection<MembershipEntity> memberships;
private PersonEntity createdBy;
private PersonEntity modifiedBy;
@Basic
@Column(name = "NAME")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Basic
@Column(name = "CREATED_DATE")
public LocalDateTime getCreatedDate() {
return createdDate;
}
public void setCreatedDate(LocalDateTime createdDate) {
this.createdDate = createdDate;
}
@Basic
@Column(name = "MODIFIED_DATE")
public LocalDateTime getModifiedDate() {
return modifiedDate;
}
public void setModifiedDate(LocalDateTime modifiedDate) {
this.modifiedDate = modifiedDate;
}
@OneToMany(mappedBy = "team")
public Collection<MembershipEntity> getMemberships() {
return memberships;
}
public void setMemberships(Collection<MembershipEntity> memberships) {
this.memberships = memberships;
}
@RestResource(rel = "team_createdBy")
@ManyToOne
@JoinColumn(name = "CREATED_BY", referencedColumnName = "ASSIGNABLE_ID", nullable = false)
public PersonEntity getCreatedBy() {
return createdBy;
}
public void setCreatedBy(PersonEntity createdBy) {
this.createdBy = createdBy;
}
@RestResource(rel = "team_modifiedBy")
@ManyToOne
@JoinColumn(name = "MODIFIED_BY", referencedColumnName = "ASSIGNABLE_ID", nullable = false)
public PersonEntity getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(PersonEntity modifiedBy) {
this.modifiedBy = modifiedBy;
}
}
İronik olarak, bu belirli kaynağa erişen değilim ben de createdBy
ve modifiedBy
ile diğer kaynaklara sahip - bu soruna neden biridir
Başka bir varlık 'createdBy' özelliği var mı? Örneğin 'PersonEntity'? – zeroflagL
Tüm varlıklarımın dört alanı vardır: '' yaratıldıBy'', '' değiştirilmişBy'', '' oluşturulanDeğer'' ve '' değiştirildiDate'' – Chad
Bu sorun olabilir. [Bu soruya] bir göz atın (http://stackoverflow.com/questions/24426644/spring-data-rest-detected-multiple-association-links-with-same-relation-type). "TeamEntity" inizdeki 'PersonEntity' öğelerinin her ikisi de oluşturulmuş bir bağlantıyı ortaya çıkarır. – zeroflagL