아동 및 부모 문서에 같은 필드에 대한 I는 다음과 같이 두 개의 클래스가 있습니다. 각 규칙의 최신 버전 만 '규칙'모음에 저장됩니다. 규칙이 업데이트되면 사본이 만들어져 'archived_rule'컬렉션에 저장됩니다.정의 지수 독립적으로 서로 다른 컬렉션
이름 필드는 '규칙'컬렉션에서 고유해야합니다. 'archived_rule'컬렉션에 복제본이 있어야합니다.
위 클래스를 정의하면 작동하지 않는 것 같습니다.
Caused by: org.springframework.data.mapping.model.MappingException: Ambiguous field mapping detected! Both @org.springframework.data.mongodb.core.index.Indexed(expireAfterSeconds=-1, dropDups=false, sparse=false, useGeneratedName=false, background=false, unique=true, name=, collection=, direction=ASCENDING) private java.lang.String ...Rule.name and @org.springframework.data.mongodb.core.index.Indexed(expireAfterSeconds=-1, dropDups=false, sparse=false, useGeneratedName=false, background=false, unique=false, name=, collection=, direction=ASCENDING) private java.lang.String ...ArchivedRule.name map to the same field name name! Disambiguate using @Field annotation!
나는 또한 ArchivedRule 클래스에 모두 이름 필드를 지정하지 않는 시도,하지만 그 경우에는 '이름'에 고유 인덱스를 생성합니다 : 내 응용 프로그램을 시작할 때, 나는 다음과 같은 예외가 필드를 'archived_rule'컬렉션에 추가하십시오.
나는 Rule과 ArchivedRule을 상속으로 무관하게 만들고, ArchivedRule의 Rule에서 저장해야하는 모든 필드를 명시 적으로 다시 정의 할 수 있다고 생각했다. 그래도 그렇게하지 않으려합니다.
Rule.name에 고유 인덱스가 있고 ArchivedRule.name에 고유 인덱스가 없도록 다른 클래스를 지정할 수 있습니까?