Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save()Java requires me to inform him which Id it must use. Why? My table uses sequences in order to generate Ids.
So after some research I found out that JPA's users must let java aware the way primary keys will be generated and we use an annotation named GeneratedValue to do this.
As my Ids are automatically generated by database, we must declare the following annotation:
@GeneratedValue(strategy=GenerationType.IDENTITY)This was the code that was generating the exception:
@Entityand now it is this way:
@Table(name = "authenticationlog", catalog = "mao", schema = "public")
public class AuthenticationLog implements Serializable {
@Id
@Column(name = "tansrvauthenticationlogid")
private Integer tansrvauthenticationlogid;
@EntityThis solved my problem. I hope it will solve yours too.
@Table(name = "authenticationlog", catalog = "mao", schema = "public")
public class AuthenticationLog implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "tansrvauthenticationlogid")
private Integer tansrvauthenticationlogid;