Hibernate Annotation Join the table issue

When you make a connection table with hibernation annotation, how to add an extra column that is not a join column, for example, as married as a weak object? how is the extra column?

@ManyToMany(targetEntity=some.class, cascade ={CascadeType.PERSIST, CascadeType.MERGE}, fetch=FetchType.EAGER) @JoinTable(name = "RELATION", joinColumns ={ @JoinColumn(name = "HID", unique = true) }, inverseJoinColumns = { @JoinColumn(name = "FID") }) Set<PERSON> PEOPLE = new HashSet<PERSON>(); 
+4
source share
1 answer

The third column technically makes this table an entity, not "compatible." Thus, the table must be the entity itself. Think about it in terms of SQL. Is a join table only a join table when it has more than just the information needed to join the other two tables?

Like FYI, this scenario is covered in Chapter 7, Java Saving (JPA) with Hibernate:

You can use two general strategies to map such a structure to Java classes. the first strategy requires an intermediate entity class for the connection table and is displayed with one-to-many associations. The second strategy uses a set of components with a value type class for the join table.

+7
source

Source: https://habr.com/ru/post/1286490/


All Articles