Hello,
I have three tables, for instance user (id, name), category (id, name) and entity_category (entity_id, entity_type, category_id). How to do join them in annotation to get Category JPA object in User JPA (I need join by constant entity_type and user id) and have possibility to save relations to entity_category table when I save User JPA?
Code:
@OneToOne
@JoinTable(name = "entity_category",
joinColumns = {
@JoinColumn(name = "entity_id", referencedColumnName="id")
},
inverseJoinColumns = {
@JoinColumn(name = "category_id")
})
@WhereJoinTable(clause = "entity_type = 1")
Code works, but entity_type isn't saved when I save user JPA object.
If possible to solve it using Hibernate 4?