1

I am using a Spring MVC server and i need to drop the database.

I use this configuration on application.properties:

spring.datasource.url=jdbc:h2:~/test;AUTO_SERVER=TRUE
spring.datasource.driverClassName=org.h2.Driver
spring.jpa.show-sql: true
spring.jpa.hibernate.ddl-auto=create-drop

And I ensure that it is used typing that in the Application's annotation:

@PropertySource("application.properties")

But the tables are not dropped, just they are loaded normally:

2014-11-18 13:30:28.231  INFO 7472 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2014-11-18 13:30:28.250  INFO 7472 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2014-11-18 13:30:28.306  INFO 7472 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {4.3.1.Final}
2014-11-18 13:30:28.307  INFO 7472 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2014-11-18 13:30:28.308  INFO 7472 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2014-11-18 13:30:28.471  INFO 7472 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
2014-11-18 13:30:32.894  INFO 7472 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2014-11-18 13:30:33.010  INFO 7472 --- [           main] o.h.h.i.ast.ASTQueryTranslatorFactory    : HHH000397: Using ASTQueryTranslatorFactory
2014-11-18 13:30:33.280  INFO 7472 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000228: Running hbm2ddl schema update
2014-11-18 13:30:33.280  INFO 7472 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000102: Fetching database metadata
2014-11-18 13:30:33.281  INFO 7472 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000396: Updating schema
2014-11-18 13:30:33.289  INFO 7472 --- [           main] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000261: Table found: TEST.PUBLIC.CLIENTE
2014-11-18 13:30:33.289  INFO 7472 --- [           main] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000037: Columns: [creation_date, id, complete_name, logginname, loggin_name]
2014-11-18 13:30:33.289  INFO 7472 --- [           main] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000108: Foreign keys: []
2014-11-18 13:30:33.289  INFO 7472 --- [           main] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000126: Indexes: [primary_key_9]

etc...

I need to force for deleting the database.

guido
  • 18,864
  • 6
  • 70
  • 95
Alberto Crespo
  • 2,429
  • 5
  • 28
  • 51

1 Answers1

1

You should try setting spring.jpa.hibernate.hbm2ddl.auto=create-drop as per this question.

Also note you need to set the generateDdl to false, due to https://jira.spring.io/browse/SPR-6836 .

Community
  • 1
  • 1
mabi
  • 5,279
  • 2
  • 43
  • 78