3 Replies Latest reply on May 30, 2008 10:31 PM by sandman202

    Reserved Words Not to Use as Entity Name

    sandman202

      Is there a list of reserved words not to use as entity names? If so, would someone please tell me where?


      I just spent an hour trying to figure out if I had a problem with my entity called InFile. The entity was never being created in the MySQL database. I looked in the server log file and found this:


      2008-05-30 12:03:02,010 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'InFile (id bigint not null auto_increment, createdOn datetime, name varchar(20),' at line 1
      



      I then tried adding the database table manually with the script and it worked. So, my next step was to copy the entity using a different name(ImportFile) and started the application server again. It worked under the different name. So, for some reason, it does not like the word InFile as an entity name.


      Any reason why? Any other names we should not use as an entity name? Is there a list somewhere?

        • 1. Re: Reserved Words Not to Use as Entity Name
          christian.bauer

          check the manual that corresponds to your MySQL server version

          • 2. Re: Reserved Words Not to Use as Entity Name
            christian.bauer

            Actually, in your case it's probably the id column name. Anyway, if the SQL server says your DDL is invalid, then it's invalid. There is no such thing as reserved entity names.


            • 3. Re: Reserved Words Not to Use as Entity Name
              sandman202

              I doubt it is related to the id column name, because I have 4 other database tables whose id field is all defined the same way:



                   public static final String FIELD_ID = "id";
              
                   private Long id;
              
                   @Id @GeneratedValue
                   @Column(name = FIELD_ID)
                   public Long getId() {
                        return id;
                   }
              
                   public void setId(Long id) {
                        this.id = id;
                   }
              



              However, you made me think about something I did the other day, which was updating the hibernate libraries in JBoss to the latest. I might of missed something when I updated the libraries or there is a problem with the hibernate library. In either case, I need to address the problem there, but my account is no longer active and I'm trying to get it reactivated to be able to post on that forum.