Note that there are some explanatory texts on larger screens.

plurals
  1. PO@MappedSuperclass and @OneToMany
    primarykey
    data
    text
    <p><a href="http://lancerx.republika.pl/images/onetoany.png" rel="nofollow">UML Diagram</a></p> <p>I need association OneToMany from Country to superclass Place (@MappedSuperclass). It could be bidirectional. I wolud need something like @OneToAny...</p> <pre><code>@MappedSuperclass public class Place { private String name; private Country country; @Column public String getName() { return name; } public void setName(String name) { this.name = name; } @ManyToOne @JoinColumn(name="country_id") public Country getCountry() { return country; } public void setCountry(Country country) { this.country = country; } } </code></pre> <p>Country:</p> <pre><code>@Entity public class Country { private long id; private String name; private List&lt;Place&gt; places; @Any(metaColumn = @Column(name = "place_type"), fetch = FetchType.EAGER) @AnyMetaDef(idType = "integer", metaType = "string", metaValues = { @MetaValue(value = "C", targetEntity = City.class), @MetaValue(value = "R", targetEntity = Region.class) }) @Cascade({ org.hibernate.annotations.CascadeType.ALL }) //@JoinColumn(name="unnecessary") //@OneToMany(mappedBy="country") // if this, NullPointerException... public List&lt;Place&gt; getPlaces() { return places; } //and rest of class </code></pre> <p>Without @JoinColunm there is exception</p> <pre><code>Caused by: org.hibernate.AnnotationException: @Any requires an explicit @JoinColumn(s): tour.spring.bc.model.vo.Country.places </code></pre> <p>In table City and Region is foreign key to table Country (Region.country_id, City.country_id) which is ok. But I do NOT need foreign key in table Country to tables Region and City so I don't need @JoinColum.</p> <p>I was looking for solution a lot but it seems there is no good solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload