当前位置: 首页 > 知识库问答 >
问题:

org.hibernate.tool.schema.spi.CommandAcceptanceException:无法执行命令

姚飞昂
2023-03-14

我刚开始使用hibernate,并尝试在oracle DB中映射已经创建的表。在下面给定的代码中:

Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();

String hql = "FROM CrbtSubMasterDemo where rownum<20";
Query query = session.createQuery(hql);

List itr = query.list();
session.getTransaction().commit();

for (Iterator iterator = itr.iterator(); iterator.hasNext();)
{
System.out.println("[" + iterator.next() + "]");
}

Apr 26, 2016 8:10:47 PM org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl processGetTableResults
INFO: HHH000262: Table not found: sdp.crbt_subscriber_master
Hibernate: create table sdp.crbt_subscriber_master (MSISDN varchar2(255) not null, STATUS varchar2(255), DATE_REGISTERED date, PLAN_INDICATOR number(10,0), RBT_CODE number(10,0), PASSWORD varchar2(255), TPIN varchar2(255), FREE_EVENTS_USED number(10,0), BLACK_LISTED number(10,0), LANGUAGE number(10,0), DEFAULT_GROUP_SETTING varchar2(255), DEFAULT_SINGLE_SETTING varchar2(255), DATE_SETTING_VALIDITY number(10,0), IMSI varchar2(255), LAST_CHARGED date, IS_MONTHLY_CHARGEABLE varchar2(255), CORP_ID number(10,0), SUB_TYPE varchar2(255), RENEW_MODE number(10,0), EXPIRY_DATE date, ACTIVE_FEATURES number(10,0), IN_USE_RBT number(10,0), UPDATE_TIME date, CORP_EXPIRY date, primary key (MSISDN))
Apr 26, 2016 8:10:47 PM org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException
WARN: GenerationTarget encountered exception accepting command : Unable to execute command [create table sdp.crbt_subscriber_master (MSISDN varchar2(255) not null, STATUS varchar2(255), DATE_REGISTERED date, PLAN_INDICATOR number(10,0), RBT_CODE number(10,0), PASSWORD varchar2(255), TPIN varchar2(255), FREE_EVENTS_USED number(10,0), BLACK_LISTED number(10,0), LANGUAGE number(10,0), DEFAULT_GROUP_SETTING varchar2(255), DEFAULT_SINGLE_SETTING varchar2(255), DATE_SETTING_VALIDITY number(10,0), IMSI varchar2(255), LAST_CHARGED date, IS_MONTHLY_CHARGEABLE varchar2(255), CORP_ID number(10,0), SUB_TYPE varchar2(255), RENEW_MODE number(10,0), EXPIRY_DATE date, ACTIVE_FEATURES number(10,0), IN_USE_RBT number(10,0), UPDATE_TIME date, CORP_EXPIRY date, primary key (MSISDN))]
org.hibernate.tool.schema.spi.CommandAcceptanceException: Unable to execute command [create table sdp.crbt_subscriber_master (MSISDN varchar2(255) not null, STATUS varchar2(255), DATE_REGISTERED date, PLAN_INDICATOR number(10,0), RBT_CODE number(10,0), PASSWORD varchar2(255), TPIN varchar2(255), FREE_EVENTS_USED number(10,0), BLACK_LISTED number(10,0), LANGUAGE number(10,0), DEFAULT_GROUP_SETTING varchar2(255), DEFAULT_SINGLE_SETTING varchar2(255), DATE_SETTING_VALIDITY number(10,0), IMSI varchar2(255), LAST_CHARGED date, IS_MONTHLY_CHARGEABLE varchar2(255), CORP_ID number(10,0), SUB_TYPE varchar2(255), RENEW_MODE number(10,0), EXPIRY_DATE date, ACTIVE_FEATURES number(10,0), IN_USE_RBT number(10,0), UPDATE_TIME date, CORP_EXPIRY date, primary key (MSISDN))]
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:63)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:567)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:551)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.createTable(SchemaMigratorImpl.java:339)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.performMigration(SchemaMigratorImpl.java:257)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:137)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:110)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:176)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:64)
    at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:458)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:465)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
    at com.telemune.demoHibernate.QueryTester.(QueryTester.java:17)
    at com.telemune.demoHibernate.QueryTester.main(QueryTester.java:21)
Caused by: java.sql.SQLException: ORA-00955: name is already used by an existing object

    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:210)
    at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:961)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190)
    at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1726)
    at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1696)
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:51)
    ... 14 more

Apr 26, 2016 8:10:47 PM org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl processGetTableResults
INFO: HHH000262: Table not found: sdp.crbt_subscriber_master
Apr 26, 2016 8:10:47 PM org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl processGetTableResults
INFO: HHH000262: Table not found: sdp.crbt_subscriber_master

然后成功显示所需的结果。但我想知道例外的原因。寻求帮助。我只知道一些关于hibenate的事情,如果这是一个愚蠢的问题,对不起。

SDP是数据库的名称。这是我的映射:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">; 
<hibernate-mapping> 
<class name="com.telemune.demoPojo.CrbtSubMasterDemo" 
table="sdp.crbt_subscriber_master"> 
<id column="MSISDN" name="mobile" type="java.lang.String">
<generator class="native"/></id> 
</hibernate-mapping>

共有1个答案

居和顺
2023-03-14

我认为问题是您在这里指定了一个带有表名的模式名

<class name="com.telemune.demoPojo.CrbtSubMasterDemo" 
  table="sdp.crbt_subscriber_master">

Hibernate将sdp.crbt_subscriber_master视为表名。

但是,当Hibernate尝试执行create table sdp.crbt_subscriber_master()时,Oracle将sdp视为架构名,而将crbt_subscriber_master视为表名。

我不知道如何为映射指定架构名称,但您可以尝试如下所述

第五章。基础O/R映射:映射-声明-类

<class name="com.telemune.demoPojo.CrbtSubMasterDemo" 
  schema="sdp" table="crbt_subscriber_master">
 类似资料:
  • 在我的Windows 10机器上安装postgres后,我很难更改与postgres用户关联的密码。我提前道歉,因为我对postgres以及使用它所需的命令非常陌生。 我在下面的文章中引用了批准的答案:致命:用户“postgres”的密码验证失败(postgresql 11和pgAdmin 4) 我被困在台阶上,需要我 我不太明白这一步。我已经采取了以下步骤 打开cmd 运行psql 然后系统向我

  • 在更新到Appengine版本1.9.10后,我无法使用maven命令mvn Appengine:update直接在Appengine上部署应用程序,并引发以下异常: [错误]找不到目标“update;”在plugin com.google.appengine中:appengine-maven-plugin:1.9.10在可用目标中[错误]使用-x开关重新运行Maven以启用完全调试日志记录。[错

  • 我没有得到“你好”:请想知道为什么和做什么

  • I使用Processbuilder如下所示: 在方法中,我设置要执行的linux命令,如下所示: 我可以从终端执行相同的命令。

  • 我在使用以下方言创建表时遇到以下错误 “org.hibernate.dialoget.mysqlinoddDialogic”

  • 我正在使用java执行一个curl命令。 我想在我的代码中获取这个curl命令的输出,但是我的stdoutout是空的。 尝试手动执行curl命令,工作正常。然后我打印了标准误差,我可以看到: 当curl命令被手动执行时,它工作得很好,那么为什么不通过Runtime.getRuntime()呢? 请建议!!任何帮助将不胜感激。