0 Replies Latest reply on Jan 17, 2008 8:14 AM by jo raksit

    assigning a column as an id for persisting

    jo raksit Newbie

      hello all,

      i'm trying to create a new record in an oracle xe database using webservices, entity and session beans. i get the error
      "Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():" when i try to create the record however.

      i have annotated a column with the id value but when i try to create the record, it doesnt seem to recognise that?

      here are my classes for clarity:

      package domain;
      import javax.persistence.*;
      import org.jboss.web.WebService;
      import org.jboss.wsf.spi.*;
      import org.jboss.wsf.spi.annotation.WebContext;
      public class Audiorec implements java.io.Serializable{
       private int Barcode_audiorec;
       private String Audiorec_alias;
       private String Serial_audiorec;
       private String Media_audiorec;
       private String Formats_audiorec;
       public Audiorec() {
       public Audiorec(String Alias, Integer Barcode, String Model, String Serial, String Media, String Formats, String Inputs, String Outputs) {
       this.Audiorec_alias = Alias;
       this.Barcode_audiorec = Barcode;
       this.Serial_audiorec = Serial;
       public String getAudiorec_alias( ) { return Audiorec_alias; }
       public void setAudiorec_alias(String alias) { this.Audiorec_alias = alias; }
       public int getBarcode_audiorec( ) { return Barcode_audiorec; }
       public void setBarcode_audiorec(int barcode) { this.Barcode_audiorec = barcode; }
       public String getSerial_audiorec( ) { return Serial_audiorec; }
       public void setSerial_audiorec(String serial) { this.Serial_audiorec = serial; }
       public String getMedia_audiorec( ) { return Media_audiorec; }
       public void setMedia_audiorec(String media) { this.Media_audiorec = media; }
       public String getFormats_audiorec( ) { return Formats_audiorec; }
       public void setFormats_audiorec(String formats) { this.Formats_audiorec = formats; }

      and my session bean:

      package Audiorec;
      import javax.ejb.Stateless;
      import javax.jws.WebMethod;
      import javax.jws.WebParam;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import domain.Audiorec;
      import javax.ejb.TransactionAttribute;
      import javax.ejb.TransactionAttributeType;
      import org.jboss.ws.annotation.*;
      import javax.jws.WebService;
      import org.jboss.wsf.spi.annotation.WebContext;
      @WebService(name="AVmanBean", serviceName="AVmanBean")
      public class AVmanBean implements AVmanRemote{
      private EntityManager manager;
       public void createAudiorec(@WebParam(name = "Alias")
      String Alias, @WebParam(name = "barcode")Integer Barcode, @WebParam(name = "serial")String Serial, @WebParam(name = "media")String Media)
       Audiorec audiorec = new Audiorec();
       public String findAudiorec(@WebParam(name = "Audiorec_alias")
       String alias) {
       Audiorec arrr = manager.find(Audiorec.class, alias);
       return arrr.getSerial_audiorec();

      i am able to search records through my webservices so i'm hoping nothing's majorly out of place but i'm a bit stumped on this id thing. i'm reading up on hibernate right now but i thought i'd just throw it out here if anyone could steer me in the right direction

      cheers for reading thus far :)