java - Custom Hibernate insert for collections, counterpart of @WhereJoinTable -
I'm trying to map a relationship with an additional feature (flag) in an additional table, but without I am clearly defining this host table in one unit.
Problem:
Trade has been assigned to 0 or 1 main country, trade is also linked to 0 or more secondary countries.
I have three tables: my I wonder what would be the equivalent Simply create a unit What I have to do, is that is_main I was wondering if any custom And the articles can also be useful (note the order of the columns in inserting statements). business ,
country ,
business_Country
business In , I have
@WhereJoinTable which works well to get back:
@OneToOne @JoinTable (name = "business_country", joinColumns = @JoinColumn (name = "business_id"), inverseJoinColumns = @JoinColumn (name = "country_id") @ @jinJinTable (volume = "is_main = 1") private country's main country; @OneToMany @JoinTable (name = "business_country", joinColumns = @JoinColumn (name = "business_id"), inverseJoinColumns = @JoinColumn (name = "country_id")) @WhereJoinTable (section = "is_main = 0") set & Lt; Country & gt; Secondary countries = new hashets & lt; & Gt; ();
@WhereJoinTable to save.
business and adding a country to do this gives an infringement violation: ("TESTSCHEMA" "BUSINESS_COUNTRY" "IS_MAIN")
1 for
main country and
is set to
for all entries in secondary countries .
@SQLInsert ?
@OneToOne @JoinTable (name = "business_country", joinColumns = JoinColumn (name = "business_id"), inverseJoinColumns = @JoinColumn (name = "country_id")) @WhereJoinTable (section = "is_main = 1 ") @SQLInsert (SQL =" enter business_country (business_id, country_id, Is_main) value (?,?, 1) ") Country of private country; @OneToMany @JoinTable (name = "business_country", joinColumns = @JoinColumn (name = "business_id"), inverseJoinColumns = @JoinColumn (name = "country_id")) @WhereJoinTable (volume = "is_main = 0") @SQLInsert (SQL = "Business_country (business_id, country_id, is_main) enter value (? in?, 0)") Private set & lt; Country & gt; Secondary countries = new hashets & lt; & Gt; ();
Comments
Post a Comment