-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Be able to disable sequence-per-table #49
Comments
The dialect doesn't check the max value of each table because it hasn't I think you may have installed the plugin in an existing application and However I'm going to think a way to provide a new dialect or configuration @Alotor, what do you think? Thanks for your report. Regards, Iván.
|
I use db-migration. Are the per-table sequences a requirement for using these extensions? If not, a nice workaround for now is to simply not run those migrations. |
You mean if using the sequence-per-table are a requirement for using this plugin? In that case no, it's not mandatory. We configured the sequence this way because we think it's better use one sequence per table instead of a global one. I'm looking into this and it seems that it's not possible to pass a parameter and get it during dialect instantiation. I think I'm going to create a different dialect. If you are using the grails-db-migration plugin you can create a groovy custom migration and set the value of the sequences with the max(id) of every table. |
I give up. Using the debugger I have access to grailsApplication and from it I can get a property to check if I've to create the sequences or not. But in runtime I get a ClassCastException. I think I'm going with two dialects :-( @Oteren do you need this new dialect asap or you can wait 2 weeks. I would like to talk with @Alotor but now he is out on holidays. |
Sooner is always better than later, but this is actually a part of a large application rewrite, so I can just work on other parts while I wait. I wouldn't mind dedicating a day or two to dig into this. If you can handle the Just point me to which file / line number you want to be able to read a boolean and I will spend the weekend looking around. |
Thank you for your offer! The sequence per table is generated here: https://github.com/kaleidos/grails-postgresql-extensions/blob/master/src/java/net/kaleidos/hibernate/PostgresqlExtensionsDialect.java#L55 I've digging around and in the superclass I've found this code: ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER ); I can execute it in my // This doesn't work
GrailsAnnotationConfiguration normalizer2 = (GrailsAnnotationConfiguration) params.get( IDENTIFIER_NORMALIZER ); With the debugger I also see that in this object the I've also being trying to create a custom config class: // This file goes in src/groovy/.....
public class MyConfig extends GrailsAnnotationConfiguration {
private GrailsApplication grailsApplication;
@Override
public void setSessionFactoryBeanName(String name) {
super.setSessionFactoryBeanName(name);
Properties p = new Properties();
p.put("myProp", "myValue");
addProperties(p);
System.out.println("Executed!");
}
public void setGrailsApplication(GrailsApplication grailsApplication) {
this.grailsApplication = grailsApplication;
}
} And use it in dataSource {
configClass = net.kaleidos.hibernate.MyConfig
dbCreate = "" // one of '', 'create', 'create-drop','update'
driverClassName = "org.postgresql.Driver"
...
} I can override a lot of methods and I have access to I hope you have more luck. Regards, Iván. |
I agree on a separate dialect, after digging around a lot and trying to read config in a sane way. |
I've found the way to read a property in the dialect. I hope to be able to create the pull request and the update in the documentation this afternoon or this night. |
Published versions 4.3.0 and 3.3.0 with a new flag for configure the sequence-per-table. Please check the documentation: https://github.com/kaleidos/grails-postgresql-extensions#configuration |
I would like a setting that allows me to keep the original PGSQL dialect that had a global sequence.
I do not know enough about sequences, but it seems to me that unless your dialect makes sure these sequences start at max(id) of the existing table, a collision might occur.
As I can see it from liquibase generation, the sequences do not take this into account.
The text was updated successfully, but these errors were encountered: