org.hibernate.tool.schema.spi.CommandAcceptanceException: Unable to execute command

19,988

I think the problem is that you specify a schema name with a table name here

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

Hibernate considers sdp.crbt_subscriber_master as a table name.

But when Hibernate tries to execute create table sdp.crbt_subscriber_master() Oracle considers sdp as a schema name and crbt_subscriber_master as a table name.

Don't know exactly how to specify a schema name for a mapping but you can try as described here

Chapter 5. Basic O/R Mapping: mapping-declaration-class

<class name="com.telemune.demoPojo.CrbtSubMasterDemo" 
  schema="sdp" table="crbt_subscriber_master">
Share:
19,988
yashpal bharadwaj
Author by

yashpal bharadwaj

Updated on July 19, 2022

Comments

  • yashpal bharadwaj
    yashpal bharadwaj almost 2 years

    I am new to hibernate and trying to map an already created Table in oracle db. in Below given code:

    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() + "]");
    }
    

    When I run this code. It First gives this Exception:

    
    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

    and then show the required result successfully. But I want to know the reason for the Exception. Asking for help. I only know some things about hibenate, sorry if its a silly question.

    sdp is the name of data base. and this is my mapping:

    <?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>
    
  • yashpal bharadwaj
    yashpal bharadwaj about 8 years
    the line I added was : String hql = "FROM CrbtSubMasterDemo where rownum<20"; I don't know why it isn't show the whole line.... And this is trying to get crbt_subscriber_master because this is the name of the mapped table with the CrbtSubMasterDemo pojo class @SkyWalker
  • yashpal bharadwaj
    yashpal bharadwaj about 8 years
    sdp is the name of data base. and this is my mapping: <?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>
  • SkyWalker
    SkyWalker about 8 years
    Actually you have the problem that the table is already exists which one is called again to create. So you have to check it that if the table exists then drop it and then try to create it.
  • SkyWalker
    SkyWalker about 8 years
    @yashpalbharadwaj To resolve ORA-00955, make sure to give the database object an unmatched name. You can also drop or modify the existing object so that it can be reused, without being identical syntax.
  • yashpal bharadwaj
    yashpal bharadwaj about 8 years
    No, I cannot Drop the table....It contains huge amount of data. I am using <property name="hbm2ddl.auto">update</property>.
  • yashpal bharadwaj
    yashpal bharadwaj about 8 years
    And yes, As I said I need to fetch data from an Already Existing Table. This will not be the resolution to the problem I think.
  • SkyWalker
    SkyWalker about 8 years
    Why this is called create table sdp.crbt_subscriber_master more times is the issue for you.
  • yashpal bharadwaj
    yashpal bharadwaj about 8 years
    Yeah, Exactly. 1. Why is it calling create Table while I am using Update + the table in sdp db already exists? 2. If it could not find the existing table how is it showing the desired result after giving this exception? 3. If it can find the existing table (as it is showing the desired result) why is it giving the table not exist and calling create?
  • SkyWalker
    SkyWalker about 8 years
    @yashpalbharadwaj I have updated the answer. Please have a try and let me know.
  • yashpal bharadwaj
    yashpal bharadwaj about 8 years
    Yeah you may be right but how should I resolve it, so that it doesn't give the Exception?
  • v.ladynev
    v.ladynev about 8 years
    @yashpalbharadwaj Please, don't edit an answer with comments :)
  • v.ladynev
    v.ladynev about 8 years
    @yashpalbharadwaj Please, see a mapping example :)
  • yashpal bharadwaj
    yashpal bharadwaj about 8 years
    when I tried to use validate instead of update INFO: HHH000262: Table not found: sdp.crbt_subscriber_master Exception in thread "main" org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [sdp.crbt_subscriber_master] at org.hibernate.tool.schema.internal.SchemaValidatorImpl.valid‌​ateTable(SchemaValid‌​atorImpl.java:130) at org.hibernate.tool.schema.internal.SchemaValidatorImpl.perfo‌​rmValidation(SchemaV‌​alidatorImpl.java:10‌​0) at org.hibernate.tool.schema.internal.SchemaValidatorImpl.doVal‌​idation(SchemaValida‌​torImpl.java:67)
  • yashpal bharadwaj
    yashpal bharadwaj about 8 years
    Yeah none solved it but will it work on the other query like Insert,update,Delete?
  • yashpal bharadwaj
    yashpal bharadwaj about 8 years
    that was a simpler one by the way ... thankyou sir @v.ladynev. Please sir can you expalin the above fact that when I replace update by none it solved the Exception Problem. How? Will it work for all other queries??
  • v.ladynev
    v.ladynev about 8 years
    @yashpalbharadwaj update = none means that Hibernate doesn't update a database schema while process a mapping (looks like there is not a none value, you can simply comment or remove hibernate.hbm2ddl.auto ). It is not any Exception, because of Hibernate doesn't try to create tables.
  • yashpal bharadwaj
    yashpal bharadwaj about 8 years
    @ v.ladynev mr. v.ladynev how can I ask my further question on hibernate directly to you?
  • v.ladynev
    v.ladynev about 8 years
    @yashpalbharadwaj It will be better, if you ask here on SO. There are a lot of people here who know Hibernate very well. And I am always here :)