2 Replies Latest reply on May 13, 2009 9:34 AM by dgeraskov

    Column Order in EJB3 / Hibernate auto generated tables

      Hi folks!

      FYI, I am using EJB3 with JBoss AS 5.0.1 and MySQL 5.1 as database.
      I use schema auto generation for my entities (EJB3 through standard annotations). I just discovered that all fields are sorted alphabetically. I would not mind this, but it is also true for my compound primary keys.

      I already posted a similar question in the EJB3 forum - but I did not receive an answer there. So as my question concerns EJB persistence with JBoss I thought my question might be answered here, as Hibernate actually runs under the hood. Please correct me if I am misstaken.

      And that is not what i want. I want to have the fields I search regularly at the beginning of the key, so that MySQL can use the key. Is there a way to take influence on the column order?

      I would like my fields to appear in the same order as defined in the entity. I already tried using @Embeddable and @EmbeddedId with and without @AttributeOverrides.

      I do not really want to name my columns a_..., b_... just to get a correct column order. Is there some documentation about this behaviour?
      Should I create the tables myself, not using table schema autogeneration?

      Thank's in advance.