Reputation: 731
I'm use hibernate JPA
hibernate
version is 3.5.1-Final
and hibernate-annotations
version is 3.5.1-Final
too
and mysql
version is : 5.5.35-0ubuntu0.12.04.2
I have a column:
@Column(name = "TITLE", length = 300)
@Index(name = "I_PRODUCT_ITEM_TITLE")
public String getTitle() {
return title;
}
but create index, show me
ERROR o.h.tool.hbm2ddl.SchemaUpdate - Unsuccessful: create index I_PRODUCT_ITEM_TITLE on T_PRODUCT_ITEM (TITLE)
ERROR o.h.tool.hbm2ddl.SchemaUpdate - BLOB/TEXT column 'TITLE' used in key specification without a key length
I don't know the reason....
Upvotes: 1
Views: 1860
Reputation: 154200
Because you specified a length of 300, the column type was set to TEXT by Hibernate.
Adding an index on a TEXT column requires you to specify a length prefix and as it seems Hibernate can't add that properly.
If you don't need a length 300 and you can live with 255 than you can go for that.
Otherwise you may choose to create the schema yourself with incremental update scripts, which is the preferred way for production systems.
You should create a Hibernate JIRA issue describing this issue. Some complained about it since 2005.
Upvotes: 1
Reputation: 2941
Jpa doesn't provide any feature to define or create indexes.You can just create unique indexes with JPA.
You can create index with hibernate.
This answer can help you to create index with hibernate..
Upvotes: 0