-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Saving problem
PostPosted: Sat Nov 20, 2010 8:37 am 
Newbie

Joined: Thu Oct 07, 2010 10:16 am
Posts: 4
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.