@@ -45,9 +45,10 @@ target(schemaExport: 'Run Hibernate SchemaExport') {
45
45
def file = new File (filename)
46
46
ant. mkdir dir : file. parentFile
47
47
48
- def configuration = appCtx. getBean(' &sessionFactory' + datasourceSuffix). configuration
48
+ def sessionFactory = appCtx. getBean(' &sessionFactory' + datasourceSuffix)
49
+ def configuration = sessionFactory. configuration
49
50
50
- def schemaExport = new HibernateSchemaExport (configuration)
51
+ def schemaExport = new HibernateSchemaExport (configuration, sessionFactory . dataSource . connection )
51
52
.setHaltOnError(true )
52
53
.setOutputFile(file. path)
53
54
.setDelimiter(' ;' )
@@ -56,17 +57,7 @@ target(schemaExport: 'Run Hibernate SchemaExport') {
56
57
String ds = argsMap. datasource ? " for DataSource '$argsMap . datasource '" : " for the default DataSource"
57
58
println " $action in environment '$grailsEnv ' $ds "
58
59
59
- if (export) {
60
- // 1st drop, warning exceptions
61
- schemaExport. execute stdout, true , true , false
62
- schemaExport. exceptions. clear()
63
- // then create
64
- schemaExport. execute stdout, true , false , true
65
- }
66
- else {
67
- // generate
68
- schemaExport. execute stdout, false , false , false
69
- }
60
+ schemaExport. execute stdout, export, false , false
70
61
71
62
if (schemaExport. exceptions) {
72
63
def e = schemaExport. exceptions[0 ]
0 commit comments