Hi,
I'm in trouble, I really don't understand something!!!
I have this object that I want to persist.
Code:
@Entity
@Table(name = "dose", catalog = "anathec")
public class Dose implements Serializable {
private DoseId id;
private Product product;
private ProductConcentration productConcentration;
private double dailyProductDose;
public Dose() {
}
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "idPatient", column = @Column(name = "id_patient", nullable = false)),
@AttributeOverride(name = "idProduct", column = @Column(name = "id_product", nullable = false)) })
public DoseId getId() {
return this.id;
}
public void setId(DoseId id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "id_product", nullable = false, insertable = false, updatable = false)
public Product getProduct() {
return this.product;
}
public void setProduct(Product product) {
this.product = product;
}
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumns({
@JoinColumn(name = "id_product", referencedColumnName = "id_product", nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "id_product_concentration", referencedColumnName = "id_product_concentration", nullable = false, insertable = false, updatable = false) })
public ProductConcentration getProductConcentration() {
return this.productConcentration;
}
public void setProductConcentration(ProductConcentration productConcentration) {
this.productConcentration = productConcentration;
}
@Column(name = "daily_product_dose", nullable = false, precision = 22, scale = 0)
public double getDailyProductDose() {
return this.dailyProductDose;
}
public void setDailyProductDose(double dailyProductDose) {
this.dailyProductDose = dailyProductDose;
}
}
But when I insert it, I have this :
Hibernate:
insert
into
anathec.dose
(daily_product_dose, id_charge, id_patient, id_product)
values
(?, ?, ?, ?)
It miss "id_product_concentration" which is non null
and this exception :
ATTENTION: SQL Error: 1364, SQLState: HY000
20 nov. 2010 13:35:09 org.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: Field 'id_product_concentration' doesn't have a default value
20 nov. 2010 13:35:09 org.hibernate.event.def.AbstractFlushingEventListener performExecutions
GRAVE: Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
I really don't understand