This content has been marked as final.
Show 4 replies
-
1. Re: @Index
epbernard Sep 1, 2005 5:04 AM (in response to jc7442)It's a bug, I've fixed it in CVS.
As a workaround, either use @Index at the class level or use explicitly @Column on elements you want to @Index -
2. Re: @Index
jc7442 Sep 1, 2005 8:10 AM (in response to jc7442)I've try several workaround and none of them works:
@Entity() @Table(name = "TaxonBO", indexes = { @Index(name = "idx", columnNames = { "mnemo" }) }) public class TaxonBO ...
or@Column(name="mnemo") @Index(name="idx") public String getMnemo() { ... }
Is there another workaround ? Which class need to be patched to fix the bug ? -
3. Re: @Index
jc7442 Sep 1, 2005 9:15 AM (in response to jc7442)It seems that this bug was referenced by:
http://opensource2.atlassian.com/projects/hibernate/browse/ANN-32
I've try to update my config to:
(mysql, hbm3.1b2, annotations3.1b4).
It still does not works. (Sorry to insist but for me that bug is a real problem. I try to bench EJB2/JDO2 vs EJB3/hibernate and without index it is not possible). -
4. Re: @Index
epbernard Sep 1, 2005 12:33 PM (in response to jc7442)Both workaround I gave you are working.
But if you want to patch, patch AnnotationBinder@@ -810,7 +810,6 @@ Column ann = (Column) annotatedElt.getAnnotation(Column.class); Formula formulaAnn = (Formula) annotatedElt.getAnnotation(Formula.class); columns = Ejb3Column.buildColumnFromAnnotation(new Column[] { ann }, formulaAnn, nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(), mappings); - columns[0].addIndex( annotatedElt.getAnnotation( Index.class ) ); } else if ( annotatedElt.isAnnotationPresent(Columns.class) ) { Columns anns = annotatedElt.getAnnotation(Columns.class); @@ -842,6 +841,15 @@ if (columns == null ) { columns = Ejb3Column.buildColumnFromAnnotation(null, null, nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(), mappings); } + + //init index + Index index = annotatedElt.getAnnotation( Index.class ); + if (index != null) { + for (Ejb3Column column : columns) { + column.addIndex( index ); + } + } + if (nullability == Nullability.FORCED_NOT_NULL) { //force columns to not null for (Ejb3Column col : columns) {
"jc7442" wrote:
It seems that this bug was referenced by:
http://opensource2.atlassian.com/projects/hibernate/browse/ANN-32
It's not the same, and this bug was a user misuse(Sorry to insist but for me that bug is a real problem. I try to bench EJB2/JDO2 vs EJB3/hibernate and without index it is not possible).
If you are doing a benchmark, why don't you just let your DBA create/tune the the DDL statements for you like in most companies. Generated DDL is more a convenient tool for developpers.