|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
getting ddl output to the consoleFor "regulatory" reasons, I can't have Hibernate/GORM create tables, etc. directly on the database. Is it possible to get these statements output to the console (or a file). I'm aware of how this is done with Hibernate, but is it possible with GORM?
Thanks, Justin |
|
|
Re: getting ddl output to the consoleI've been struggling with this myself - there should be a simple way to use
the Hibernate-generated DDL as an initial script that a DBA can customize for production. In regular Spring/Hibernate apps I use the Ant tasks (which wrap SchemaExport) but am having trouble figuring out how to build the Configuration using .groovy files as domain classes. SchemaExport does call "log.debug(formatted);" though so as a temporary measure I configured debug logging in Config.groovy for category 'org.hibernate.tool.hbm2dll' and I capture the DDL from the log4j output. Burt On Monday 11 February 2008 10:52:27 pm Justin Edelson wrote: > For "regulatory" reasons, I can't have Hibernate/GORM create tables, etc. > directly on the database. Is it possible to get these statements output to > the console (or a file). I'm aware of how this is done with Hibernate, but > is it possible with GORM? > > Thanks, > Justin --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: getting ddl output to the consoleSounds like a need for a "grails generate-ddl" script. That would be awesome...
+1 Jason On Feb 12, 2008 4:04 AM, Burt Beckwith <burt@...> wrote: I've been struggling with this myself - there should be a simple way to use |
|
|
Re: getting ddl output to the consoleBurt,
Could you give a little more detail on how you call SchemaExport to get the debug to output the DDL? Where/how are you calling SchemaExport within the loaded Grails app? By the way, I've added jira issues for "generate-ddl" (http://jira.codehaus.org/browse/GRAILS-2760) and "generate-hbm-xml" (http://jira.codehaus.org/browse/GRAILS-2761) commands. Thanks, Jon On Mon, Feb 11, 2008 at 10:04 PM, Burt Beckwith <burt@...> wrote: > I've been struggling with this myself - there should be a simple way to use > the Hibernate-generated DDL as an initial script that a DBA can customize for > production. In regular Spring/Hibernate apps I use the Ant tasks (which wrap > SchemaExport) but am having trouble figuring out how to build the > Configuration using .groovy files as domain classes. > > SchemaExport does call "log.debug(formatted);" though so as a temporary > measure I configured debug logging in Config.groovy for > category 'org.hibernate.tool.hbm2dll' and I capture the DDL from the log4j > output. > > Burt > > > > On Monday 11 February 2008 10:52:27 pm Justin Edelson wrote: > > For "regulatory" reasons, I can't have Hibernate/GORM create tables, etc. > > directly on the database. Is it possible to get these statements output to > > the console (or a file). I'm aware of how this is done with Hibernate, but > > is it possible with GORM? > > > > Thanks, > > Justin > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: getting ddl output to the consoleNever mind, I think this is what Burt was suggesting to get hibernate
to output the DDL: 1) set org.'hibernate.tool.hbm2ddl'="debug" in the log4j settings in Config.groovy 2) set dbCreate to "create-drop" 3) start grails When grails starts up and the schema is dropped and created, you will see all of the ddl printed to stdout: [2797] hbm2ddl.SchemaExport Running hbm2ddl schema export [2812] hbm2ddl.SchemaExport import file not found: /import.sql [2812] hbm2ddl.SchemaExport exporting generated schema to database [2812] hbm2ddl.SchemaExport alter table bibliography drop foreign key FK563143626D2169FE ... I was missing step 2 since I was mapping against a legacy database. Jon On Mon, Mar 31, 2008 at 4:06 PM, Jon Gunnip <jongunnip@...> wrote: > Burt, > > Could you give a little more detail on how you call SchemaExport to > get the debug to output the DDL? Where/how are you calling > SchemaExport within the loaded Grails app? > > By the way, I've added jira issues for "generate-ddl" > (http://jira.codehaus.org/browse/GRAILS-2760) and "generate-hbm-xml" > (http://jira.codehaus.org/browse/GRAILS-2761) commands. > > Thanks, > Jon > > > > On Mon, Feb 11, 2008 at 10:04 PM, Burt Beckwith <burt@...> wrote: > > I've been struggling with this myself - there should be a simple way to use > > the Hibernate-generated DDL as an initial script that a DBA can customize for > > production. In regular Spring/Hibernate apps I use the Ant tasks (which wrap > > SchemaExport) but am having trouble figuring out how to build the > > Configuration using .groovy files as domain classes. > > > > SchemaExport does call "log.debug(formatted);" though so as a temporary > > measure I configured debug logging in Config.groovy for > > category 'org.hibernate.tool.hbm2dll' and I capture the DDL from the log4j > > output. > > > > Burt > > > > > > > > On Monday 11 February 2008 10:52:27 pm Justin Edelson wrote: > > > For "regulatory" reasons, I can't have Hibernate/GORM create tables, etc. > > > directly on the database. Is it possible to get these statements output to > > > the console (or a file). I'm aware of how this is done with Hibernate, but > > > is it possible with GORM? > > > > > > Thanks, > > > Justin > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe from this list, please visit: > > > > http://xircles.codehaus.org/manage_email > > > > > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: getting ddl output to the consoleThis works, but it's clumsy because you have to capture the logging output
manually. I wrote a Gant script that's pretty flexible; I started writing it up a while back but got distracted. I finished the writeup and have a link to the script here: http://burtbeckwith.com/blog/?p=59 Burt On Monday 31 March 2008 9:34:04 pm Jon Gunnip wrote: > Never mind, I think this is what Burt was suggesting to get hibernate > to output the DDL: > 1) set org.'hibernate.tool.hbm2ddl'="debug" in the log4j settings in > Config.groovy > 2) set dbCreate to "create-drop" > 3) start grails > > When grails starts up and the schema is dropped and created, you will > see all of the ddl printed to stdout: > > [2797] hbm2ddl.SchemaExport Running hbm2ddl schema export > [2812] hbm2ddl.SchemaExport import file not found: /import.sql > [2812] hbm2ddl.SchemaExport exporting generated schema to database > [2812] hbm2ddl.SchemaExport alter table bibliography drop foreign key > FK563143626D2169FE > ... > > I was missing step 2 since I was mapping against a legacy database. > > Jon > > On Mon, Mar 31, 2008 at 4:06 PM, Jon Gunnip <jongunnip@...> wrote: > > Burt, > > > > Could you give a little more detail on how you call SchemaExport to > > get the debug to output the DDL? Where/how are you calling > > SchemaExport within the loaded Grails app? > > > > By the way, I've added jira issues for "generate-ddl" > > (http://jira.codehaus.org/browse/GRAILS-2760) and "generate-hbm-xml" > > (http://jira.codehaus.org/browse/GRAILS-2761) commands. > > > > Thanks, > > Jon > > > > On Mon, Feb 11, 2008 at 10:04 PM, Burt Beckwith <burt@...> > > > I've been struggling with this myself - there should be a simple way > > > to use the Hibernate-generated DDL as an initial script that a DBA can > > > customize for production. In regular Spring/Hibernate apps I use the > > > Ant tasks (which wrap SchemaExport) but am having trouble figuring out > > > how to build the Configuration using .groovy files as domain classes. > > > > > > SchemaExport does call "log.debug(formatted);" though so as a > > > temporary measure I configured debug logging in Config.groovy for > > > category 'org.hibernate.tool.hbm2dll' and I capture the DDL from the > > > log4j output. > > > > > > Burt > > > > > > On Monday 11 February 2008 10:52:27 pm Justin Edelson wrote: > > > > For "regulatory" reasons, I can't have Hibernate/GORM create > > > > tables, etc. directly on the database. Is it possible to get these > > > > statements output to the console (or a file). I'm aware of how this > > > > is done with Hibernate, but is it possible with GORM? > > > > > > > > Thanks, > > > > Justin > > > > > > --------------------------------------------------------------------- > > > To unsubscribe from this list, please visit: > > > > > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: getting ddl output to the consoleBurt-
This looks great. Thanks. On Mon, Mar 31, 2008 at 9:42 PM, Burt Beckwith <burt@...> wrote: This works, but it's clumsy because you have to capture the logging output |
| Free embeddable forum powered by Nabble | Forum Help |