1 Reply Latest reply on Feb 3, 2006 2:47 PM by acoliver

    why is it inserting nulls in my id column... since grabbing

    acoliver

       

      01:12:21,113 INFO [STDOUT] Hibernate: insert into Folder (name, parent_id, TYPE, id) values (?, ?, 'org.jboss.mail.mailbox.Folder', null)
      01:12:21,120 WARN [JDBCExceptionReporter] SQL Error: -10, SQLState: 23000
      01:12:21,121 ERROR [JDBCExceptionReporter] Attempt to insert null into a non-nullable column: column: ID table: FOLDER in statement [insert into Folder (name, parent_id, TYPE, id) values (?, ?, 'org.jboss.mail.mailbox.Folder', null)]
      01:12:21,123 ERROR [[HtmlAdaptor]] Servlet.service() for servlet HtmlAdaptor threw exception
      


      Now I have:

      @Entity @Inheritance(strategy=javax.persistence.InheritanceType.SINGLE_TABLE)
      public class Folder implements Serializable {
      ...
       /**
       * @return surrogate key
       */
       @Id @GeneratedValue(strategy=GenerationType.AUTO)
       public long getId() {
       return id;
       }
      
       protected void setId(long id) {
       this.id = id;
       }
      ...
      }
      


      @Entity @Inheritance(strategy=javax.persistence.InheritanceType.SINGLE_TABLE)
      public class Mailbox extends Folder implements Serializable {
      ...
      
      ...
      }
      


       /*
       * (non-Javadoc)
       *
       * @see org.jboss.mail.mailbox.MailboxService#createMailbox(java.lang.String)
       */
       @Tx(TxType.REQUIRED)
       public Mailbox createMailbox(String alias) {
       emInit();
       Mailbox box = new Mailbox();
       Alias aliasObj = new Alias();
       aliasObj.setName(alias);
       box.addAlias(aliasObj);
       Folder inbox = new Folder();
       inbox.setName("INBOX");
       inbox.setParent(box);
       box.setDefaultInFolder(inbox);
       box.setDefaultOutFolder(inbox);
       session.persist(box);
       session.persist(inbox);
       session.persist(aliasObj);
       return box;
       }
      


      Some of the goody redundency was in the attempt to fix this. I started out with field access. Note that this code worked under JBAS 403 SP1 before upgrade to EJB3 RC5.