Grails does not concern sequencia

0

in my database I have the following:

id bigint NOT NULL DEFAULT nextval('seq_telefonosnormalizados'::regclass),

While in grails I have the following:

static mapping = {
        id column:"id", sqlType:"long", generator:'sequence', params:[sequence:'seq_telefonosnormalizados']
        version false
    }

I'm using Grails 2.5.1.

Does anyone know why it would not be working?

Of course, thank you very much!

    
asked by JuanManuel245 19.10.2018 в 19:58
source

2 answers

1

Ok. Better tell you about my experience ...

MySQL generates the sequences by default, so when it receives a new data record order it increases to the next position ... and, it is not by order of grails as it only takes care of link them and restructure the tree of the BD according to the configuration programmed in the domain.

For example:
I need to manipulate the events that an administrator performs in an X system; the importance of my approach is that there should only be one administrator in that table called admin for example. Then there will be no new registrations but perhaps the modification of the data of that admin and, so that new registrations are not allowed, I preferred to program it from the admin controller to make sure that nobody by malice includes a different admin and enter my control.

    
answered by 28.10.2018 в 03:27
0

At the end I solved it by creating a sequence in postgresql, and telling grails and the table that they should follow that sequence!

    
answered by 31.10.2018 в 14:26