]
Steve Ebersole commented on HIBERNATE-112:
------------------------------------------
This is not the correct project to report Hibernate issues under. This Jira project is for
reporting issues in the integration between Hibernate and WildFly. To report issues in
Hibernate, please use
. Thanks.
Also the referenced issue in the proper Jira system indicates that the issue was
resolved.
Schema auto generation creates columns in alphabetical order for
compound primary keys
--------------------------------------------------------------------------------------
Key: HIBERNATE-112
URL:
https://issues.jboss.org/browse/HIBERNATE-112
Project: Hibernate Integration
Issue Type: Bug
Environment: JBoss AS 5.0.1 with EJB3 entities / Hibernate with MySQL Server 5.1
Reporter: Jochen Reinhardt
Assignee: Steve Ebersole
Schema auto generation creates columns in alphabetical order.
I would not mind that, but it also affects the creation of primary key indexes. These are
rather useless from a database point of view, as the database will only be able to use an
index for searching if the columns that are searched for are a prefix of the key.
Alphabetical column order is not what one expects. Instead, I would want that my columns
are sorted in the same way they appear in my annotated POJO class. I hope I am not missing
some simple configuration issue...
I have a rather complex setup with my entities and relations, using compound primary keys
and references. In an entity that maps a complex m:n relationship between two entities
with additional properties... Please let me know if you need more details.
I'm using @Embedded on a primary key class and @EmbeddedId in all my entities.
I already posted in the Hibernate forums, but I did not get an answer yet, nor did I find
any information about my specific problem. The only peace of information I found so far
is, that the alphabetical column sort order was introduced because of some issues related
to foreign key constraints in clustered environments. As it is already somewhat urgent, I
decided to submit a bug report.
A colleague of mine found the following in some other forum and I looked up in the source
code, too - it's still there. But I do not know if it is correct in general and it
only does not work for my setup.
Cite:
Hi all,
I am using EJB3 with hibernate.hbm2ddl.auto=update. I notice the primary keys is been
created in database in alphabetic order and not like the order defined at the embedded
class. I look at the source code of Hibernate Annotations and found in AnnotationBinder
class a Collections.sort at line 1024 with this comment:
//order so that property are used in the same order when binding native query
In my project I have primary keys with 4 or 5 fields, and many queries use only 2 ou 3 of
them and are running very slow, and the cause was the wrong order of the primary keys in
the database.
I guest that sort is for fixing another bug, but is really annoying, because I need to
look each primary key and adjust its order by hand.
Is there another solution?
Thanks in advance.