I want to run a test with JUnit and Hibernate an in-memory database HSQLDB, but when the method is trying to commit the changes to the DB, this exception appears: (No Spring framework)
我想用JUnit和Hibernate运行一个内存数据库HSQLDB测试,但是当该方法试图将更改提交给DB时,会出现此异常:(无Spring框架)
Caused by: java.sql.SQLException: invalid schema name: SRH in statement [select liquidacio0_.idLiquidacion as idLiquid1_180_0_, liquidacio0_.fkEstado as fkEstado180_0_, liquidacio0_.FECHA_LIQ as FECHA3_180_0_, liquidacio0_.DIAS_LIQUIDAR as DIAS4_180_0_, liquidacio0_.MES_DIAS as MES5_180_0_, liquidacio0_.MES_LIQUIDACION as MES6_180_0_, liquidacio0_.LIQUIDACION_TVAC as LIQUIDAC7_180_0_, liquidacio0_.FECHA_ESTADO as FECHA8_180_0_, liquidacio0_.fkSolicitud as fkSolici9_180_0_, liquidacio0_.idTvac as idTvac180_0_, liquidacio0_.NUMLIQ as NUMLIQ180_0_, liquidacio0_.legajo as legajo180_0_, liquidacio0_.periodo as periodo180_0_ from srh.srh_liquidacion liquidacio0_ where liquidacio0_.idLiquidacion=?]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
The exception occurs here:
此处发生异常:
sesionActiva.getTransaction().commit();
My hibernateTest.cfg.xml:
我的hibernateTest.cfg.xml:
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:mem:testdb</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<!--<property name="hibernate.default_schema">srh</property>-->
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">10</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="pkgClasesDeNegocio/pkgAdministracionNovedadAsistencia/Liquidacion.hbm.xml"/>
//And others
</session-factory>
</hibernate-configuration>
My Liquidacion.hbm.xml:
我的Liquidacion.hbm.xml:
<hibernate-mapping>
<class catalog="srh" name="pkgClasesDeNegocio.pkgAdministracionNovedadAsistencia.Liquidacion" table="srh_liquidacion">
<id name="idLiquidacion" type="java.lang.Integer">
<column name="idLiquidacion"/>
<generator class="identity"/>
</id>
<many-to-one class="pkgClasesDeNegocio.pkgAdministracionNovedadAsistencia.Estado" lazy="false" fetch="select" name="estado">
<column name="fkEstado" not-null="true"/>
</many-to-one>
<property name="fechaLiquidacion" type="date">
<column length="10" name="FECHA_LIQ"/>
</property>
<property name="cantDiasALiquidar">
<column name="DIAS_LIQUIDAR"/>
</property>
<property name="mesDeDias" type="string">
<column length="50" name="MES_DIAS"/>
</property>
<property name="mesDeLiquidacion" type="string">
<column length="50" name="MES_LIQUIDACION"/>
</property>
<property name="fechaLiquidacionTvac" type="string">
<column length="50" name="LIQUIDACION_TVAC"/>
</property>
<property name="fechaEstado" type="date">
<column length="10" name="FECHA_ESTADO"/>
</property>
<many-to-one class="pkgClasesDeNegocio.pkgAdministracionNovedadAsistencia.SolicitudVacaciones" lazy="false" fetch="select" name="solicitud">
<column name="fkSolicitud" not-null="true"/>
</many-to-one>
<property name="idTvac">
<column name="idTvac"/>
</property>
<property name="nroLiquidacion">
<column name="NUMLIQ"/>
</property>
<property name="legajo">
<column name="legajo"/>
</property>
<property name="periodo">
<column name="periodo"/>
</property>
</class>
2 个解决方案
#1
0
Try removing catalog="srh". This might be the problem: http://forums.mysql.com/read.php?39,137564,137629#msg-137629
尝试删除catalog =“srh”。这可能是问题:http://forums.mysql.com/read.php?39,137564,137629#msg-137629
#2
0
changed the schema name to PUBLIC and it worked (PUBLIC should be the name of the schema) -;) , all other schema names did not work and gave the "Invalid schema ..name " error. Thanks to an old post i found here https://sourceforge.net/p/unitils/discussion/570578/thread/a887838e/
将模式名称更改为PUBLIC并且它有效(PUBLIC应该是模式的名称) - ;),所有其他模式名称都不起作用并且给出了“Invalid schema ..name”错误。感谢我在这里找到的旧帖子https://sourceforge.net/p/unitils/discussion/570578/thread/a887838e/
#1
0
Try removing catalog="srh". This might be the problem: http://forums.mysql.com/read.php?39,137564,137629#msg-137629
尝试删除catalog =“srh”。这可能是问题:http://forums.mysql.com/read.php?39,137564,137629#msg-137629
#2
0
changed the schema name to PUBLIC and it worked (PUBLIC should be the name of the schema) -;) , all other schema names did not work and gave the "Invalid schema ..name " error. Thanks to an old post i found here https://sourceforge.net/p/unitils/discussion/570578/thread/a887838e/
将模式名称更改为PUBLIC并且它有效(PUBLIC应该是模式的名称) - ;),所有其他模式名称都不起作用并且给出了“Invalid schema ..name”错误。感谢我在这里找到的旧帖子https://sourceforge.net/p/unitils/discussion/570578/thread/a887838e/