-->
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: Hibernate doesn't create correct INSERT statement
PostPosted: Mon Sep 22, 2008 6:17 am 
Newbie

Joined: Mon Sep 22, 2008 6:13 am
Posts: 1
Hello!

I've the following problem when creating a table for MetaDataUpdates..

Code:
Hibernate: insert into MetadataUpdate_KiWiExtendedTriple (MetadataUpdateId, currentTripleId) values (?, ?)
ERROR [org.hibernate.util.JDBCExceptionReporter] Field 'prevTripleId' doesn't have a default value


The insert statement should normally insert 3 values: MetadataUpdateId, currentTripleId and prevTripleId. currentTriple and prevTriple are both persisted in the Database. After persisting MetadataUpdate (and em.flush), the above error is printed.

Here's my MetadataUpdate class:

Code:
package kiwi.model.revision;

import java.io.Serializable;

@Entity
public class MetadataUpdate extends KiWiUpdate implements Serializable {

   /**
    *
    */
   private static final long serialVersionUID = 1157304931584263193L;
   
   @OneToOne
   private KiWiSpecialResource resource;
   
   private Date date;

   /* TripleStore - Metadata */
   @OneToMany(cascade={CascadeType.PERSIST})
   private Set<KiWiExtendedTriple> prevTriple;
   @OneToMany(cascade={CascadeType.PERSIST})
   private Set<KiWiExtendedTriple> currentTriple;
   
   @ManyToOne
   private Revision revision;
   
   public MetadataUpdate() {
      
   }

   /**
    * @return the currentTriple
    */
   public Set<KiWiExtendedTriple> getCurrentTriple() {
      return currentTriple;
   }

   /**
    * @param currentTriple the currentTriple to set
    */
   public void setCurrentTriple(Set<KiWiExtendedTriple> currentTriple) {
      this.currentTriple = currentTriple;
   }

   /**
    * @return the prevTriple
    */
   public Set<KiWiExtendedTriple> getPrevTriple() {
      return prevTriple;
   }

   /**
    * @param prevTriple the prevTriple to set
    */
   public void setPrevTriple(Set<KiWiExtendedTriple> prevTriple) {
      this.prevTriple = prevTriple;
   }
       
        [...]
}


And that's my KiWiExtendedTriple class:

Code:
@Entity
public class KiWiExtendedTriple  implements Serializable {
   
   /**
    *
    */
   private static final long serialVersionUID = -8726615974625660845L;

   @Id
   @DocumentId
   @GeneratedValue(strategy=GenerationType.TABLE)
   private Long id;
   
   @Transient
        KiWiTripleStore context;
   
        @OneToOne(cascade={CascadeType.PERSIST})
        KiWiResource    subject;
        @OneToOne(cascade={CascadeType.PERSIST})
        KiWiUriResource property;
        @OneToOne(cascade={CascadeType.PERSIST})
        KiWiNode        object;
   
        @OneToOne(cascade={CascadeType.PERSIST})
        KiWiResource tripleId;

        @OneToOne
        User  author;
   
   
   
   public KiWiExtendedTriple(KiWiTripleStore context, KiWiResource subject, KiWiUriResource property, KiWiNode object) {
        this.context = context;
        this.subject = subject;
        this.property = property;
        this.object   = object;
        this.tripleId = context.createAnonResource();
    }

   public KiWiExtendedTriple(KiWiTripleStore context, KiWiResource subject, KiWiUriResource property, KiWiNode object, KiWiUriResource tripleId) {
        this.context = context;
        this.subject = subject;
        this.property = property;
        this.object   = object;
        this.tripleId = tripleId;
    }

    [...]
}


I'm using Seam, but I don't know if this problem related to Seam or Hibernate


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.