3 Replies Latest reply on Nov 29, 2006 3:49 PM by tsar_bomba

    Column name clash with SQL keyword

    herkules

      Hi,

      This simple entity won't work with EJB3:

      public class Attribute implements Serializable {
      
       private Long id;
      
       private Byte order;
      
       @Id
       @GeneratedValue
       public Long getId() {
       return id;
       }
      
       public void setId(Long id) {
       this.id = id;
       }
      
       public Byte getOrder() {
       return order;
       }
      
       public void setOrder(final Byte order) {
       this.order = order;
       }
      }
      


      Because JBoss/Hibernate doesn't escape column names with quotes (or DB specific escaping):

      create table Attribute (id bigint generated by default as identity (start with 1), order tinyint)
      ..
      Unexpected token: ORDER in statement
      


      I don't want to use artificial name for the column, I'd rather see something like this:

      create table Attribute (id bigint generated by default as identity (start with 1), 'order' tinyint)
      


      Is there a (db independent) solution?

      Thanks Jan