0
Hello, good morning, sir. Having a table that relates USER and ACHIEVEMENTS called USER_ACHIEVEMENTS, where it does not have ID, only USER_ID and ACHIEVEMENTS_ID, ie a manyToMany relationship.
How to map this table in Hibernate, without it having an ID?
Follow my class Entity:
@Entity
@Table(name="USER_ACHIEVEMENTS")
public class UserAchievements {
@Column(name="USER_ID", nullable=false)
private int userId;
@Column(name="ACHIEVEMENTS_ID", nullable=false)
private int achievementsId;
When running the project, with this class mapped this way, the error below happens:
Caused by: org.hibernate.Annotationexception: No Identifier specified for Entity: com.poli.server.PoliServer.Model.Userachievements
You have two ways to map this kind of relationship, you can create an associative entity, which is how you’re doing it or you can just map from within the entities .
– Isaías de Lima Coelho