jboss - Hibernate SchemaExport fails to first create schema -
i running tests using arquillian, jboss, jpa/hibernate, h2 db , maven. in test persistence.xml file have:
<property name="hibernate.hbm2ddl.auto" value="create-drop" /> <property name="hibernate.show_sql" value="true" />
for have single user class mapped 'users' table via hibernate annotations.
things working. problem hibernate trying execute:
drop table my_schema.users if exists
but schema, 'my_schema' doesn't exist fails (i'm running against in-memory db after all).
how hibernate execute 'create schema my_schema' step seems forgetting?
update: messages see hibernate:
09:42:45,402 info [org.jboss.as.jpa] (msc service thread 1-7) jbas011402: starting persistence unit service 'test.war#ccmc' 09:42:45,524 info [org.hibernate.annotations.common.version] (msc service thread 1-7) hcann000001: hibernate commons annotations {4.0.1.final} 09:42:45,532 info [org.hibernate.version] (msc service thread 1-7) hhh000412: hibernate core {4.0.1.final} 09:42:45,535 info [org.hibernate.cfg.environment] (msc service thread 1-7) hhh000206: hibernate.properties not found 09:42:45,542 info [org.hibernate.cfg.environment] (msc service thread 1-7) hhh000021: bytecode provider name : javassist 09:42:45,572 info [org.hibernate.ejb.ejb3configuration] (msc service thread 1-7) hhh000204: processing persistenceunitinfo [ name: ccmc ...] 09:42:45,739 info [org.hibernate.service.jdbc.connections.internal.connectionproviderinitiator] (msc service thread 1-7) hhh000130: instantiating explicit connection provider: org.hibernate.ejb.connection.injecteddatasourceconnectionprovider 09:42:45,956 info [org.hibernate.dialect.dialect] (msc service thread 1-7) hhh000400: using dialect: org.hibernate.dialect.h2dialect 09:42:45,962 warn [org.hibernate.dialect.h2dialect] (msc service thread 1-7) hhh000431: unable determine h2 database version, features may not work 09:42:45,965 info [org.hibernate.engine.jdbc.internal.lobcreatorbuilder] (msc service thread 1-7) hhh000423: disabling contextual lob creation jdbc driver reported jdbc version [3] less 4 09:42:45,973 info [org.hibernate.engine.transaction.internal.transactionfactoryinitiator] (msc service thread 1-7) hhh000268: transaction strategy: org.hibernate.engine.transaction.internal.jta.cmttransactionfactory 09:42:45,976 info [org.hibernate.hql.internal.ast.astquerytranslatorfactory] (msc service thread 1-7) hhh000397: using astquerytranslatorfactory 09:42:46,003 info [org.hibernate.validator.util.version] (msc service thread 1-7) hibernate validator 4.2.0.final 09:42:46,269 info [org.hibernate.tool.hbm2ddl.schemaexport] (msc service thread 1-7) hhh000227: running hbm2ddl schema export 09:42:46,275 info [stdout] (msc service thread 1-7) hibernate: drop table ccmc.users if exists 09:42:46,283 error [org.hibernate.tool.hbm2ddl.schemaexport] (msc service thread 1-7) hhh000389: unsuccessful: drop table ccmc.users if exists 09:42:46,283 error [org.hibernate.tool.hbm2ddl.schemaexport] (msc service thread 1-7) schema "ccmc" not found; sql statement: drop table ccmc.users if exists [90079-161] 09:42:46,284 info [stdout] (msc service thread 1-7) hibernate: create table ccmc.users (user_id decimal(19,2) generated default identity, email varchar(100) not null unique, primary key (user_id)) 09:42:46,285 error [org.hibernate.tool.hbm2ddl.schemaexport] (msc service thread 1-7) hhh000389: unsuccessful: create table ccmc.users (user_id decimal(19,2) generated default identity, email varchar(100) not null unique, primary key (user_id)) 09:42:46,285 error [org.hibernate.tool.hbm2ddl.schemaexport] (msc service thread 1-7) schema "ccmc" not found; sql statement: create table ccmc.users (user_id decimal(19,2) generated default identity, email varchar(100) not null unique, primary key (user_id)) [90079-161] 09:42:46,286 info [org.hibernate.tool.hbm2ddl.schemaexport] (msc service thread 1-7) hhh000230: schema export complete
i found answer in so question.
when defining connection url db, needs added: "init=create schema if not exists ". full url in persistence.xml file looks like:
<connection-url>jdbc:h2:mem:test-db;db_close_delay=-1;init=create schema if not exists ccmc</connection-url>
Comments
Post a Comment