Hibernate JPA how to convert list-index hbm attribute to annotations? -



Hibernate JPA how to convert list-index hbm attribute to annotations? -

i want convert existing hbm file jpa entity via annotations. next hbm code want convert annotation:

<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>

my problem attribute list-index, tried utilize indexes element jointable got exception

@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>();

the unit test :

@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); }

i got exception

caused by: org.hibernate.annotationexception: unable 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. create sure utilize right column name depends on naming strategy in utilize (it may not same property name in entity, relational types) @ org.hibernate.cfg.configuration.builduniquekeyfromcolumnnames(configuration.java:1682) @ org.hibernate.cfg.configuration.secondpasscompile(configuration.java:1457) @ org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:1844) @ org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl$4.perform(entitymanagerfactorybuilderimpl.java:850) ... 62 more

i think need @ordercolumn

@ordercolumn(name="type_comparution_courrier_types_courriers_idx") @manytomany(cascade = {cascadetype.all},fetch = fetchtype.eager) @jointable(name = "types_comparutions2types_courriers",indexes = { 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>();

hibernate jpa jpa-2.0 spring-data-jpa hbm

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -