-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: How to control index columns sequence while creating table?
PostPosted: Thu Feb 14, 2008 5:28 am 
Newbie

Joined: Mon Apr 09, 2007 4:24 am
Posts: 4
I use Hibernate Annotation to mark some fields to be contained in an index like :

@Index(name = "sn")
@Column(length = 2, nullable = false, updatable = false)
private String srvCode = null;

@Index(name = "sn")
@Column(length = 2, nullable = false, updatable = false)
private String cityCode = null;

@Index(name = "sn")
@Column(length = 2, nullable = false, updatable = false)
private String regionCode = null;

@Index(name = "sn")
@Column(nullable = false, updatable = false)
private long sn = -1;

And I expect the index should be created as the sequence of fields declaration order as : srvCode, cityCode, regionCode, sn.

But the actual sequence (cityCode, regionCode, sn, srvCode) seems sorted by the fields name.

Actually the columns creation sequence in a table also sorted too.

Is that causing by the usage of TreeMap inside of the SchemaExport process ?

What can I do to make the index columns created by the fields declaration order but not sorted ?

[b]Hibernate version:[/b]
Hibernate 3.2.5
Hibernate Annotation 3.3.0 GA

[b]Mapping documents:[/b]
by annotation

[b]Name and version of the database you are using:[/b]
MySQL 5.0.45-22.2

[b]The generated SQL (show_sql=true):[/b]
2008-02-14 16:41:26,755 DEBUG SchemaExport:303 - create table floody_test.Quotation (id varchar(32) not null, verLock integer not null, ..., cityCode varchar(2) not null, regionCode varchar(2) not null, sn bigint not null, srvCode varchar(2) not null, ..., primary key (id))
2008-02-14 16:41:32,296 DEBUG SchemaExport:303 - create index sn on floody_test.Quotation (cityCode, regionCode, sn, srvCode)


Top
 Profile  
 
 Post subject: Use Annotations 3.2.1 GA is fine.
PostPosted: Fri Feb 15, 2008 3:20 am 
Newbie

Joined: Mon Apr 09, 2007 4:24 am
Posts: 4
I test with numerous versions of Hibernate Core and Hibernate Annotations combinations to try to solve above problem.

The test result is :
Use Hibernate Annotations 3.2.1 GA combine with Hibernate Core 3.2.x will not face with this problem. Once replace the Annotations library to 3.3.0.GA this problem is show up again.

Thus the problem is not causing by Hibernate Core but Annotations 3.3.0 GA.

What is the difference between Annotations 3.2.1 and 3.3.0 that changes the schema export behavior?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 19, 2008 8:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The returned list of properties is not deterministic in some VMs, so I had to order it.

org.hibernate.Table.indexes will help you define a column ordering for your indexes.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.