gpt4 book ai didi

java - org.h2.jdbc.JdbcSQLException : Schema "SYS" not found; SQL statement: select name from sys. 序列 [90079-192]

转载 作者:行者123 更新时间:2023-12-02 14:04:29 28 4
gpt4 key购买 nike

我正在使用嵌入式 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com