7 Replies Latest reply on Mar 10, 2008 8:07 AM by Sascha Hoffmann

    ORA-00904

    Sascha Hoffmann Newbie

      Hi

      I have a problem with my EntityBean but i don't know why. I hapoe somebody can help me.

      Ouput in the JBoss-Console

      10:43:14,296 WARN [JDBCExceptionReporter] SQL Error: 904, SQLState: 42000
      10:43:14,296 ERROR [JDBCExceptionReporter] ORA-00904: Ungültiger Spaltenname
      


      My EntityBean "LOV_User.java"
      package tcejb;
      
      import javax.persistence.*;
      
      @Entity
      @NamedQueries({
       @NamedQuery(name="LOV_USER.findByName",
       query="SELECT l FROM LOV_User l WHERE l.user = ?1 ")
      })
      @Table(name="LOV_USER")
      public class LOV_User implements java.io.Serializable {
      
       private static final long serialVersionUID = 1;
      
       private String user;
       private String user_name;
       private String user_password;
       private int admin_sign;
       private String status_sign;
       private String new_date;
       private String update_date;
       private String last_user;
      
       @Id
       @Column(name="LOV_USR_USER")
       public String getUser() {return user;}
       public void setUser(String user) {this.user = user;}
      
       @Column(name="LOV_USR_USER_NAME")
       public String getUserName() {return user_name;}
       public void setUserName(String user_name) {this.user_name = user_name;}
      
       @Column(name="LOV_USR_USER_PASSWORD")
       public String getUserPassword() {return user_password;}
       public void setUserPassword(String user_password) {this.user_password = user_password;}
      
       @Column(name="LOV_USR_ADMIN_SIGN")
       public int getAdminSign() {return admin_sign;}
       public void setAdminSign(int admin_sign) {this.admin_sign = admin_sign;}
      
       @Column(name="LOV_USR_STAUS_SIGN")
       public String getStatusSign() {return status_sign;}
       public void setStatusSign(String status_sign) {this.status_sign = status_sign;}
      
       @Column(name="LOV_USR_NEW_DATE")
       public String getNewDate() {return new_date;}
       public void setNewDate(String new_date) {this.new_date = new_date;}
      
       @Column(name="LOV_USR_UPDATE_DATE")
       public String getUpdateDate() {return update_date;}
       public void setUpdateDate(String update_date) {this.update_date = update_date;}
      
       @Column(name="LOV_USR_LAST_USER")
       public String getLastUser() {return last_user;}
       public void setLastUser(String last_user) {this.last_user = last_user;}
      }
      


      My StatefulBean
      package tcejb;
      
      import java.util.List;
      import java.util.Vector;
      import javax.ejb.*;
      import javax.persistence.*;
      
      @Stateful
      public class LoginBean implements LoginRemote {
       @PersistenceContext(unitName="tcdb")
       private EntityManager manager;
      
       private String user;
      
       @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
       public void initialisieren(String key) {
       Query query = manager.createNamedQuery("LOV_USER.findByName");
       query.setParameter(1, key);
       List liste = query.getResultList();
       Vector<LOV_User> erg = new Vector<LOV_User>();
       for(Object o : liste)
       {
       erg.add((LOV_User) o);
       }
       user = erg.toString();
       }
      
       @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
       public String getUser() {return user;}
      
       @Remove
       public void remove() {
      
       }
      
      }
      


      Please somebody get me a solution. I have no idea why the Column name is not ok. If i write the column-name from the database-table the same message pop up.

        • 1. Re: ORA-00904
          Sandor Fiedler Newbie

          "user" is a reserved word for oracle. Just annotate your field user with something like

          @Column(name="MyUser")
          private String user;
          

          Best regards
          /sandor/

          • 2. Re: ORA-00904
            Sascha Hoffmann Newbie

            I have renamed my user-variable but know i get a new error-code

            11:29:59,093 ERROR [SessionFactoryImpl] Error in named query: LOV_USER.findByName
            org.hibernate.QueryException: could not resolve property: nutzer of: tcejb.LOV_User [SELECT l FROM tcejb.LOV_User l WHERE l.nutzer = ?1 ]
             at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
            .......
            


            My new EntityBean
            package tcejb;
            
            import javax.persistence.*;
            
            @Entity
            @NamedQueries({
             @NamedQuery(name="LOV_USER.findByName",
             query="SELECT l FROM LOV_User l WHERE l.nutzer = ?1 ")
            })
            @Table(name="LOV_USER")
            public class LOV_User implements java.io.Serializable {
            
             private static final long serialVersionUID = 1;
            
             private String nutzer;
             private String user_name;
             private String user_password;
             private int admin_sign;
             private String status_sign;
             private String new_date;
             private String update_date;
             private String last_user;
            
             @Id
             @Column(name="LOV_USR_USER")
             public String getUser() {return nutzer;}
             public void setUser(String benutzer) {this.nutzer = benutzer;}
            
             @Column(name="LOV_USR_USER_NAME")
             public String getUserName() {return user_name;}
             public void setUserName(String user_name) {this.user_name = user_name;}
            
             @Column(name="LOV_USR_USER_PASSWORD")
             public String getUserPassword() {return user_password;}
             public void setUserPassword(String user_password) {this.user_password = user_password;}
            
             @Column(name="LOV_USR_ADMIN_SIGN")
             public int getAdminSign() {return admin_sign;}
             public void setAdminSign(int admin_sign) {this.admin_sign = admin_sign;}
            
             @Column(name="LOV_USR_STAUS_SIGN")
             public String getStatusSign() {return status_sign;}
             public void setStatusSign(String status_sign) {this.status_sign = status_sign;}
            
             @Column(name="LOV_USR_NEW_DATE")
             public String getNewDate() {return new_date;}
             public void setNewDate(String new_date) {this.new_date = new_date;}
            
             @Column(name="LOV_USR_UPDATE_DATE")
             public String getUpdateDate() {return update_date;}
             public void setUpdateDate(String update_date) {this.update_date = update_date;}
            
             @Column(name="LOV_USR_LAST_USER")
             public String getLastUser() {return last_user;}
             public void setLastUser(String last_user) {this.last_user = last_user;}
            }
            


            • 3. Re: ORA-00904
              Sandor Fiedler Newbie

              delete or alter the relevant table

              • 4. Re: ORA-00904
                Sascha Hoffmann Newbie

                What?
                Why i should delete the table? I don't understand the meening of yout posting sorry.
                My English is not so good, please explain what you mean.
                What should i alter in the table?

                • 5. Re: ORA-00904
                  Sascha Hoffmann Newbie

                   

                  package tcejb;
                  
                  import javax.persistence.*;
                  
                  @Entity
                  @NamedQueries({
                   @NamedQuery(name="LOV_USER.findByName",
                   query="SELECT l FROM LOV_User l WHERE l.nutzer = ?1 ")
                  })
                  @Table(name="LOV_USER")
                  public class LOV_User implements java.io.Serializable {
                  
                   private static final long serialVersionUID = 1;
                  
                   private String nutzer;
                   private String user_name;
                   private String user_password;
                   private int admin_sign;
                   private String status_sign;
                   private String new_date;
                   private String update_date;
                   private String last_user;
                  
                   @Id
                   @Column(name="LOV_USR_USER")
                   public String getNutzer() {return nutzer;}
                   public void setNutzer(String benutzer) {this.nutzer = benutzer;}
                  
                   @Column(name="LOV_USR_USER_NAME")
                   public String getUserName() {return user_name;}
                   public void setUserName(String user_name) {this.user_name = user_name;}
                  
                   @Column(name="LOV_USR_USER_PASSWORD")
                   public String getUserPassword() {return user_password;}
                   public void setUserPassword(String user_password) {this.user_password = user_password;}
                  
                   @Column(name="LOV_USR_ADMIN_SIGN")
                   public int getAdminSign() {return admin_sign;}
                   public void setAdminSign(int admin_sign) {this.admin_sign = admin_sign;}
                  
                   @Column(name="LOV_USR_STAUS_SIGN")
                   public String getStatusSign() {return status_sign;}
                   public void setStatusSign(String status_sign) {this.status_sign = status_sign;}
                  
                   @Column(name="LOV_USR_NEW_DATE")
                   public String getNewDate() {return new_date;}
                   public void setNewDate(String new_date) {this.new_date = new_date;}
                  
                   @Column(name="LOV_USR_UPDATE_DATE")
                   public String getUpdateDate() {return update_date;}
                   public void setUpdateDate(String update_date) {this.update_date = update_date;}
                  
                   @Column(name="LOV_USR_LAST_USER")
                   public String getLastUser() {return last_user;}
                   public void setLastUser(String last_user) {this.last_user = last_user;}
                  }
                  
                  

                  I changed my EntityBean and now i have no user-variable.
                  But i get the same Error-Code as i descriped in the first posting.

                  12:21:34,453 WARN [JDBCExceptionReporter] SQL Error: 904, SQLState: 42000
                  12:21:34,453 ERROR [JDBCExceptionReporter] ORA-00904: Ungültiger Spaltenname
                  


                  Where is the problem? The column name in the "@Column(name="LOV_USR_USER")" ist correct.

                  • 6. Re: ORA-00904
                    Sandor Fiedler Newbie

                    ok,

                    first aof all, make sure your defined column name are not longer then 20 signs and your table name are not longer than 30 sign (this restriction belong to oracle).

                    Then check out your created tables and make sure, your defined column name are reflected correct. If not and you can delete your table (i.e. there is no important data inside), than delet that table and let the entity manager create a new one. Otherwise you must alter your table definition by using any sql ddl commands (i.e. "alter table xxx ...").

                    • 7. Re: ORA-00904
                      Sascha Hoffmann Newbie

                      Thank you very much!!!! *smile*

                      I had a mistake in my ColumnName(name="LOV_USR_STATUS")

                      Now everything is ok.

                      Thanks