I tried following this reference and this is now my domain's code:
class SnbrActVector {
long nid
String term
double weight
static mapping = {
version false
nid index:'Nid_Idx'
}
static constraints = {
term(blank:false)
}
}
What I want is to d开发者_如何学运维o is to add an index key for the nid
column. I dropped the existing table and ran the app again so the table is then recreated. However, when I check for list of indices, I can't see an Nid_Idx
, only PRIMARY
. Do I have to manually create the index and name it Nid_idx
in my mysql database?
Yes, it's working only when using dbCreate = "create"
.
Let's say I have an empty database and my dbCreate
set to "update"
. In this case index is not created.
Your syntax is correct so it might be another problem or a Grails bug. My advice :
- Create a new grails application (
grails create-app
) withSnbrActVector
as the only domain (grails create-domain...
). Copy your code inside. - Check that your DataSource.groovy file has
dbCreate = "create-drop"
- Verify the indices of the SnbrActVector table.
If you see an index created for nid
column, then it means that there is problem in your application (you might not have used "create-drop" or something else)
If the index is NOT created => This is a grails bug and you should open a JIRA issue here
You might need to add the column name to get it to fire e.g.
static mapping = {
version false
nid column:'nid', index:'Nid_Idx'
}
精彩评论