I have this table in some application, with a generator specified and a Generationtype.AUTO, but whenever I try to persist it, I get an error from the server saying id does not have a default value. This is running on a jboss server AS7.x and the database engine is mysql.
So far I have no conclusion as to why does it happen. Can anyone help?
@SequenceGenerator(name = "id", sequenceName = "some_set_seq", initialValue = 1, allocationSize = 1)
@Table(name = "some_set")
public class SomeSet implements Serializable {
private static final long serialVersionUID = 633453570945334348L;
private long id;
private String name;
private String description;
private List<SomeItem> items;
private List<SomeEntity> someEntities;
private Date lastModification;
public SomeSet() {}
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "id")
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Column(name = "name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "description")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@OneToMany(cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.FALSE)
@JoinColumn(name = "some_set_id")
@ForeignKey(name="FK_someItem_someSet")
public List<SomeItem> getItems() {
return items;
}
public void setItems(List<SomeItem> items) {
this.items = items;
}
@ManyToMany(mappedBy = "someSets", cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
@ForeignKey(name="FK_someLink_someSet")
public List<SomeEntity> getEntities() {
return someEntities;
}
public void setEntities(List<SomeEntity> someEntities) {
this.someEntities = someEntities;
}
@EntityProperty(name = "lastmodificationdate")
@Column(name = "last_modification_date")
public Date getLastModification() {
return lastModification;
}
public void setLastModification(Date lastModification) {
this.lastModification = lastModification;
}
}