주석을 통해 기존 hbm 파일을 JPA 엔티티로 변환하려고합니다. 다음 내가 주석으로 변환 할 HBM 코드 :Hibernate JPA 목록 인덱스 hbm 속성을 주석으로 변환하는 방법은 무엇입니까?
, 나는 관절 식으로 인덱스 요소를 사용하려고하지만 예외@ManyToMany(cascade = {CascadeType.ALL},fetch = FetchType.EAGER)
@JoinTable(name = "TYPES_COMPARUTIONS2TYPES_COURRIERS",indexes = { @Index(columnList="TYPE_COMPARUTION_COURRIER_TYPES_COURRIERS_IDX", name="TYPE_COMPARUTION_COURRIER_TYPES_COURRIERS_IDX") } ,joinColumns = {
@JoinColumn(name = "TYPES_COMPARUTIONS_FK", nullable = false, updatable = false) },
inverseJoinColumns = { @JoinColumn(name = "TYPES_COURRIERS_FK", nullable = false, updatable = false) })
private Set<TypeCourrier> typeCourriers= new HashSet<TypeCourrier>();
있어 내 문제는 속성리스트 인덱스 함께
<list name="typesCourriers" table="TYPES_COMPARUTIONS2TYPES_COURRIERS" inverse="false">
<key foreign-key="TYPE_COURRIER_TYPES_COMPARUTIONS_FKC">
<column name="TYPES_COMPARUTIONS_FK" sql-type="BIGINT"/>
</key>
<list-index column="TYPE_COMPARUTION_COURRIER_TYPES_COURRIERS_IDX"/>
<many-to-many class="TypeCourrier" foreign-key="TYPE_COMPARUTION_COURRIER_TYPES_COURRIEC">
<column name="TYPES_COURRIERS_FK" sql-type="BIGINT"/>
</many-to-many>
</list>
단위 테스트 :
@Test
public void test() {
TypeComparutionCourrier typeComparutionCourrier=repository.findOne(new Long(1));
System.out.println(typeComparutionCourrier);
for(TypeCourrier typeCourrier:typeComparutionCourrier.getTypeCourriers())
{
System.out.println(typeCourrier);
}
typeComparutionCourrier.getTypeCourriers().add(typecourrierrepository.findOne(new Long(9)));
System.out.println(("*********"));
for(TypeCourrier typeCourrier:typeComparutionCourrier.getTypeCourriers())
{
System.out.println(typeCourrier);
}
repository.save(typeComparutionCourrier);
}
나는이 예외를 가지고
Caused by: org.hibernate.AnnotationException: Unable to create unique key constraint (TYPE_COMPARUTION_COURRIER_TYPES_COURRIERS_IDX) on table TYPES_COMPARUTIONS2TYPES_COURRIERS: database column 'TYPE_COMPARUTION_COURRIER_TYPES_COURRIERS_IDX' not found. Make sure that you use the correct column name which depends on the naming strategy in use (it may not be the same as the property name in the entity, especially for relational types)
at org.hibernate.cfg.Configuration.buildUniqueKeyFromColumnNames(Configuration.java:1682)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1457)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
... 62 more
필요하다고 생각? – CoverosGene
@CoverosGene 예가 존재합니다 – Moussi