- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用嵌入式 H2 数据库为 DAO 对象创建一个单元测试类。但是,当我尝试运行它时,出现了与“SYS”模式相关的异常,但无法找到该模式。
存储库配置
package com.csms.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.*;
import org.springframework.core.env.Environment;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.Properties;
@Configuration
@ComponentScan(basePackages = "com.csms")
@PropertySource(value = "classpath:db.properties")
@EnableTransactionManagement
public class RepositoryConfig {
@Autowired
private Environment env;
@Bean(name = "dataSource")
@Profile("prod")
public DataSource dataSourceForProd() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("db.driver"));
dataSource.setUrl(env.getProperty("db.url"));
dataSource.setUsername(env.getProperty("db.user"));
dataSource.setPassword(env.getProperty("db.password"));
return dataSource;
}
@Bean(name = "dataSource")
@Profile("test")
public DataSource dataSourceForTest() {
return new EmbeddedDatabaseBuilder()
.generateUniqueName(true)
.setType(EmbeddedDatabaseType.H2)
.ignoreFailedDrops(true)
.addScript("schema.sql")
.addScript("data.sql")
.build();
}
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
adapter.setShowSql(true);
adapter.setGenerateDdl(true);
adapter.setDatabase(Database.SQL_SERVER);
adapter.setDatabasePlatform("org.hibernate.dialect.SQLServer2012Dialect");
return adapter;
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(
DataSource dataSource, JpaVendorAdapter jpaVendorAdapter
) {
Properties props = new Properties();
props.setProperty("hibernate.format_sql", String.valueOf(true));
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource);
emf.setJpaVendorAdapter(jpaVendorAdapter);
emf.setPackagesToScan("com.csms.entities");
emf.setJpaProperties(props);
return emf;
}
@Bean
public BeanPostProcessor persistenceTranslation() {
return new PersistenceExceptionTranslationPostProcessor();
}
@Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
return new JpaTransactionManager(emf);
}
}
schema.sql
CREATE TABLE Customer (
CustID nvarchar(20) NOT NULL,
CustomerID nvarchar(50) NOT NULL,
Address nvarchar(50),
Phone nvarchar(20),
Fax nvarchar(20),
Email nvarchar(50),
Overdue int NOT NULL,
Amount decimal(18),
OverdueAmt decimal(18),
DueAmt decimal(18),
Status nchar(2) NOT NULL,
Description nvarchar(200),
PRIMARY KEY (CustID)
);
CREATE TABLE "Group" (
GroupID nvarchar(20) NOT NULL,
GroupName nvarchar(50) NOT NULL,
PRIMARY KEY (GroupID)
);
CREATE TABLE Inventory (
InvtID nvarchar(20) NOT NULL,
InvtName nvarchar(50) NOT NULL,
ClassName nvarchar(50),
UnitID_T int,
UnitID_L int NOT NULL,
UnitRate int,
SalesPriceT decimal(18),
SalesPriceL decimal(18),
QtyStock int,
SlsTax decimal(18),
Status nchar(2) NOT NULL,
Description nvarchar(200),
PRIMARY KEY (InvtID)
);
CREATE TABLE InvoiceType (
InvoiceType nvarchar(2) NOT NULL,
InvoiceName nvarchar(50),
PRIMARY KEY (InvoiceType)
);
CREATE TABLE MoneyTransaction (
TransID nvarchar(20) NOT NULL,
TransDate date NOT NULL,
TransAmt decimal(18,1) NOT NULL,
Description nvarchar(200),
PRIMARY KEY (TransID)
);
CREATE TABLE OrderType (
OrderType nchar(2) NOT NULL,
TypeName nvarchar(50) NOT NULL,
PRIMARY KEY (OrderType)
);
CREATE TABLE Payment (
PaymentID int NOT NULL,
PaymentNo nvarchar(20) NOT NULL,
PaymentDate date,
PaymentAmt decimal(18),
CustID nvarchar(20),
SalesPersonID nvarchar(20),
Description nvarchar(200),
PRIMARY KEY (PaymentID)
);
CREATE TABLE PurchaseOrdDetail (
OrderNo nvarchar(20) NOT NULL,
InvtID nvarchar(20) NOT NULL,
Qty int,
PurchasePrice decimal(18),
StockID nvarchar(20),
QtyProm int,
QtyPromAmt decimal(18),
AmtProm decimal(18),
TaxAmt decimal(18),
Amount decimal(18),
PRIMARY KEY (InvtID,OrderNo)
);
CREATE TABLE PurchaseOrder (
OrderNo nvarchar(20) NOT NULL,
OrderDate date,
OrderType nchar(2) NOT NULL,
OverdueDate date,
DiscAmt decimal(18),
PromAmt decimal(18),
ComAmt decimal(18),
TaxAmt decimal(18),
TotalAmt decimal(18),
PRIMARY KEY (OrderNo)
);
CREATE TABLE SalesOrder (
OrderNo nvarchar(20) NOT NULL,
OrderDate date NOT NULL,
InvoiceType nvarchar(2) NOT NULL,
CustID nvarchar(20) NOT NULL,
OverdueDate date NOT NULL,
OrderDisc decimal(18) NOT NULL,
TaxAmt decimal(18),
TotalAmt decimal(18),
Payment decimal(18),
Debt decimal(18),
Description nvarchar(200),
PRIMARY KEY (OrderNo)
);
CREATE TABLE SalesPerson (
SalesPersonID nvarchar(20) NOT NULL,
SalesPersonName nvarchar(50) NOT NULL,
Address nvarchar(50),
StockQuota int,
Status nchar(2) NOT NULL,
Description nvarchar(200),
PRIMARY KEY (SalesPersonID)
);
CREATE TABLE SlsOrderDetail (
ID int NOT NULL,
OrderNo nvarchar(20) NOT NULL,
InvtID nvarchar(20) NOT NULL,
Qty int,
SalesPrice decimal(18),
Discount decimal(18),
TaxAmt decimal(18),
Amount decimal(18),
PRIMARY KEY (ID)
);
CREATE TABLE Status (
Status nchar(2) NOT NULL,
StatusName nvarchar(50) NOT NULL,
PRIMARY KEY (Status)
);
CREATE TABLE StkTransDetail (
TransID nvarchar(20) NOT NULL,
InvtID nvarchar(20) NOT NULL,
Qty int,
Amount decimal(18),
PRIMARY KEY (InvtID,TransID)
);
CREATE TABLE Stock (
StockID nvarchar(20) NOT NULL,
StockName nvarchar(50) NOT NULL,
PRIMARY KEY (StockID)
);
CREATE TABLE StockInspection (
StockInspID nvarchar(20) NOT NULL,
StockInspDate date NOT NULL,
Description nvarchar(200),
PRIMARY KEY (StockInspID)
);
CREATE TABLE StockTransfer (
TransID nvarchar(20) NOT NULL,
TransDate date,
FromStockID nvarchar(20) NOT NULL,
ToStockID nvarchar(20) NOT NULL,
TotalAmt decimal(18),
Description nvarchar(200),
PRIMARY KEY (TransID)
);
CREATE TABLE Unit (
UnitID int NOT NULL,
UnitName nvarchar(50) NOT NULL,
PRIMARY KEY (UnitID)
);
CREATE TABLE "User" (
UserID nvarchar(20) NOT NULL,
UserName nvarchar(20) NOT NULL,
Password nvarchar(50) NOT NULL,
GroupID nvarchar(20) NOT NULL,
PRIMARY KEY (UserID)
);
CREATE TABLE Vendor (
VendorID nvarchar(20) NOT NULL,
VendorName nvarchar(50) NOT NULL,
Address nvarchar(50),
Email nvarchar(50),
Phone nvarchar(20),
Fax nvarchar(20),
DueAmt decimal(18),
Amount decimal(18),
OverdueAmt decimal(18),
Status nchar(2) NOT NULL,
Description nvarchar(200),
PRIMARY KEY (VendorID)
);
ALTER TABLE Customer
ADD FOREIGN KEY (Status)
REFERENCES Status (Status);
ALTER TABLE Inventory
ADD FOREIGN KEY (Status)
REFERENCES Status (Status);
ALTER TABLE Inventory
ADD FOREIGN KEY (UnitID_L,UnitID_T)
REFERENCES Unit (UnitID,UnitID);
ALTER TABLE Payment
ADD FOREIGN KEY (CustID)
REFERENCES Customer (CustID);
ALTER TABLE Payment
ADD FOREIGN KEY (SalesPersonID)
REFERENCES SalesPerson (SalesPersonID);
ALTER TABLE PurchaseOrdDetail
ADD FOREIGN KEY (InvtID)
REFERENCES Inventory (InvtID);
ALTER TABLE PurchaseOrdDetail
ADD FOREIGN KEY (OrderNo)
REFERENCES PurchaseOrder (OrderNo);
ALTER TABLE PurchaseOrdDetail
ADD FOREIGN KEY (StockID)
REFERENCES Stock (StockID);
ALTER TABLE PurchaseOrder
ADD FOREIGN KEY (OrderType)
REFERENCES OrderType (OrderType);
ALTER TABLE SalesOrder
ADD FOREIGN KEY (CustID)
REFERENCES Customer (CustID);
ALTER TABLE SalesOrder
ADD FOREIGN KEY (InvoiceType)
REFERENCES InvoiceType (InvoiceType);
ALTER TABLE SalesPerson
ADD FOREIGN KEY (Status)
REFERENCES Status (Status);
ALTER TABLE SlsOrderDetail
ADD FOREIGN KEY (OrderNo)
REFERENCES SalesOrder (OrderNo);
ALTER TABLE StkTransDetail
ADD FOREIGN KEY (InvtID)
REFERENCES Inventory (InvtID);
ALTER TABLE StkTransDetail
ADD FOREIGN KEY (TransID)
REFERENCES StockTransfer (TransID);
ALTER TABLE StockTransfer
ADD FOREIGN KEY (FromStockID,ToStockID)
REFERENCES Stock (StockID,StockID);
ALTER TABLE "User"
ADD FOREIGN KEY (GroupID)
REFERENCES "Group" (GroupID);
ALTER TABLE Vendor
ADD FOREIGN KEY (Status)
REFERENCES Status (Status);
数据.sql
INSERT INTO Status(Status, StatusName) VALUES ('AV', 'Active');
INSERT INTO Status(Status, StatusName) VALUES ('UA', 'Inactive');
INSERT INTO Status(Status, StatusName) VALUES ('DE', 'Deleted');
StatusDAOUnitTest.java
package com.csms.dao;
import com.csms.config.RepositoryConfig;
import com.csms.entities.Status;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.core.Is.is;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = RepositoryConfig.class)
@Transactional
@ActiveProfiles("test")
public class StatusDAOUnitTest {
@Autowired
private StatusDAO statusDAO;
@Test
public void testGetStatusList() {
List<Status> statusList = statusDAO.getStatusList();
assertThat(statusList.size(), is(3));
}
}
堆栈跟踪
org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.command.Parser.getSchema(Parser.java:679)
at org.h2.command.Parser.getSchema(Parser.java:685)
at org.h2.command.Parser.readTableFilter(Parser.java:1215)
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1896)
at org.h2.command.Parser.parseSelectSimple(Parser.java:2044)
at org.h2.command.Parser.parseSelectSub(Parser.java:1890)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1711)
at org.h2.command.Parser.parseSelect(Parser.java:1699)
at org.h2.command.Parser.parsePrepared(Parser.java:445)
at org.h2.command.Parser.parse(Parser.java:317)
at org.h2.command.Parser.parse(Parser.java:289)
at org.h2.command.Parser.prepareCommand(Parser.java:254)
at org.h2.engine.Session.prepareLocal(Session.java:560)
at org.h2.engine.Session.prepareCommand(Session.java:501)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1202)
at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:73)
at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.extractMetadata(SequenceInformationExtractorLegacyImpl.java:42)
at org.hibernate.tool.schema.internal.exec.ImprovedDatabaseInformationImpl.initializeSequences(ImprovedDatabaseInformationImpl.java:63)
at org.hibernate.tool.schema.internal.exec.ImprovedDatabaseInformationImpl.<init>(ImprovedDatabaseInformationImpl.java:57)
at org.hibernate.tool.schema.internal.Helper.buildDatabaseInformation(Helper.java:126)
... 56 more
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:253)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactoryBean' defined in com.csms.config.RepositoryConfig: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1076)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:851)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:128)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:108)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:251)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
... 29 more
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:961)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:891)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:338)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 44 more
Caused by: org.hibernate.exception.GenericJDBCException: Unable to build DatabaseInformation
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
at org.hibernate.tool.schema.internal.Helper.buildDatabaseInformation(Helper.java:134)
at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:97)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:176)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:65)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:308)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:483)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888)
... 50 more
Caused by: org.h2.jdbc.JdbcSQLException: Schema "SYS" not found; SQL statement:
select name from sys.sequences [90079-192]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.command.Parser.getSchema(Parser.java:679)
at org.h2.command.Parser.getSchema(Parser.java:685)
at org.h2.command.Parser.readTableFilter(Parser.java:1215)
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1896)
at org.h2.command.Parser.parseSelectSimple(Parser.java:2044)
at org.h2.command.Parser.parseSelectSub(Parser.java:1890)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1711)
at org.h2.command.Parser.parseSelect(Parser.java:1699)
at org.h2.command.Parser.parsePrepared(Parser.java:445)
at org.h2.command.Parser.parse(Parser.java:317)
at org.h2.command.Parser.parse(Parser.java:289)
at org.h2.command.Parser.prepareCommand(Parser.java:254)
at org.h2.engine.Session.prepareLocal(Session.java:560)
at org.h2.engine.Session.prepareCommand(Session.java:501)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1202)
at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:73)
at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.extractMetadata(SequenceInformationExtractorLegacyImpl.java:42)
at org.hibernate.tool.schema.internal.exec.ImprovedDatabaseInformationImpl.initializeSequences(ImprovedDatabaseInformationImpl.java:63)
at org.hibernate.tool.schema.internal.exec.ImprovedDatabaseInformationImpl.<init>(ImprovedDatabaseInformationImpl.java:57)
at org.hibernate.tool.schema.internal.Helper.buildDatabaseInformation(Helper.java:126)
... 56 more
Process finished with exit code -1
最佳答案
我发现了问题。我分别为 MSSQL 和嵌入式 H2 创建了两个单独的配置文件“prod”和“test”,然后将两个数据源分配给这两个配置文件。但我忘记创建一个新的 JpaVendorAdapter 进行测试,因此“测试”配置文件使用了错误的 JpaVendorAdapter 配置。我所需要的只是为 H2 数据库创建一个 JpaVendorAdapter 并为其提供“测试”配置文件。
关于java - org.h2.jdbc.JdbcSQLException : Schema "SYS" not found; SQL statement: select name from sys. 序列 [90079-192],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38821204/
SQL、PL-SQL 和 T-SQL 之间有什么区别? 谁能解释一下这三者之间的区别,并提供每一个的相关使用场景? 最佳答案 SQL 是一种对集合进行操作的查询语言。 它或多或少是标准化的,几乎所有关
这个问题已经有答案了: What is the difference between SQL, PL-SQL and T-SQL? (6 个回答) 已关闭 9 年前。 我对 SQL 的了解足以完成我的
我在数据库中有一个 USER 表。该表有一个 RegistrationDate 列,该列有一个默认约束为 GETDATE()。 使用 LINQ 时,我没有为 RegistrationDate 列提供任
我有一个可能属于以下类型的字符串 string expected result 15-th-rp 15 15/12-rp 12 15-12-th
很难说出这里问的是什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或言辞激烈,无法以目前的形式合理回答。如需帮助澄清此问题以便可以重新打开,visit the help center . 9年前关闭
我有一个存储过程(称为 sprocGetArticles),它从文章表中返回文章列表。这个存储过程没有任何参数。 用户可以对每篇文章发表评论,我将这些评论存储在由文章 ID 链接的评论表中。 有什么方
我目前正在做一个 *cough*Oracle*cough* 数据库主题。讲师介绍embedded SQL作为让其他语言(例如 C、C++)与(Oracle)数据库交互的方式。 我自己做了一些数据库工作
SQL Server 中 SQL 语句的最大长度是多少?这个长度是否取决于 SQL Server 的版本? 例如,在 DECLARE @SQLStatement NVARCHAR(MAX) = N'S
这个问题已经有答案了: Simple way to transpose columns and rows in SQL? (9 个回答) 已关闭 8 年前。 CallType
预先感谢您对此提供的任何帮助。 假设我有一个查询,可以比较跨年的数据,从某个任意年份开始,永无止境(进入 future ),每年同一时期直到最后一个完整的月份(其特点是一月数据永远不会显示至 2 月
我在数据库中有一个 USER 表。该表有一个 RegistrationDate 列,该列的默认约束为 GETDATE()。 使用 LINQ 时,我没有为 RegistrationDate 列提供任何数
下面是我试图用来检查存储过程是否不存在然后创建过程的 sql。它会抛出一个错误:Incorrect syntax near the keyword 'PROCEDURE' IF NOT EXISTS
我有一个同事声称动态 SQL 在许多情况下比静态 SQL 执行得更快,所以我经常看到 DSQL 到处都是。除了明显的缺点,比如在运行之前无法检测到错误并且更难阅读,这是否准确?当我问他为什么一直使用
来自 lobodava 的动态 SQL 查询是: declare @sql nvarchar(4000) = N';with cteColumnts (ORDINAL_POSITION, CO
使用 SQL Server 中的存储过程执行动态 SQL 命令的现实优点和缺点是什么 EXEC (@SQL) 对比 EXEC SP_EXECUTESQL @SQL ? 最佳答案 sp_executes
我有这个有效的 SQL 查询: select sum(dbos.Points) as Points, dboseasons.Year from dbo.StatLines dbos i
我正在调试一些构建成功运行的 SQL 命令的代码。 然而,在查询结束时,查询结果似乎被写入了一个文本文件。 完整的查询如下 echo SELECT DATE,DATETABLE,DATE,APPDAT
我有一些创建表的 .sql 文件(MS SQL 数据库): 表_1.sql: IF OBJECT_ID (N'my_schema.table1', N'U') IS NOT NULL DROP TAB
我写了下面的 SQL 存储过程,它一直给我错误@pid = SELECT MAX(... 整个过程是: Alter PROCEDURE insert_partyco @pname varchar(20
我在 SQL Server 2005 中有包含两列 Fruit 和 Color 的表,如下所示 Fruit Colour Apple Red Orange
我是一名优秀的程序员,十分优秀!