@Manytomany add extra field with no join Entity
I created a @ManyToMany relation between two table, without have a relational entity through them. Something like this:
@Entity
public class Category{
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "CATEGORY_ID", unique = true, nullable = false)
private Long categoryId;
}
@Entity
public class Content {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "CONTENT_ID", unique = true, nullable = false)
private Long contentId;
@ManyToMany(fetch=FetchType.LAZY)
@JoinTable(
name="CATEGORIES_CONTENTS",
joinColumns={
@JoinColumn(name="CONTENT_ID",
referencedColumnName="CONTENT_ID",
nullable = false)},
inverseJoinColumns={
@JoinColumn(name="CATEGORY_ID",
referencedColumnName="CATEGORY_ID",
nullable = false)
})
private List<Category> categories;
}
Now, after the end 开发者_运维技巧of the project, I have the need to add an extra field in the relational table to handle a new feature.
Is it possible to do that, without create the related entity? I don't want to change a lot of things.
I already read this good article: Can add extra field(s) to @ManyToMany Hibernate extra table?
but it isn't what I need.
Tanks a lot, Davide.
精彩评论