-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: problem with <generator class="sequence"/>
PostPosted: Mon Feb 23, 2009 7:52 pm 
Regular
Regular

Joined: Wed Jan 28, 2009 8:31 pm
Posts: 54
Hi I have a problem with generator sequence
this is my hbm
Code:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="ca.canassistance.pojo">
<class
      name="Xc4dvoyPojo"
      table="XC4DVOY"
   >
      
            <id name="id" type="integer" unsaved-value="null" column="ID">
            <generator class="sequence">
            <param name="sequence">ma_sequence</param>
            </generator>
      </id>
<property
name="sttRegistnNum"
column="STT-REGISTN-NUM"
type="string"
not-null="false"
length="12"
/>
<property
name="sttRecordType"
column="STT_RECORD_TYPE"
type="string"
not-null="false"
length="1"
/>
<property
name="sttServiceLineNum"
column="STT_SERVICE_LINE_NUM"
type="integer"
not-null="false"
length="5"
/>
<property
name="sttAdjustmentAction"
column="STT_ADJUSTMENT_ACTION"
type="string"
not-null="false"
length="5"
/>

</class>
</hibernate-mapping>


and my hibernate console


Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory >

      <!-- local connection properties -->
      <property name="hibernate.connection.url">jdbc:oracle:thin:@s1ora01s:1521:s1ora01i</property>
      <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
      <property name="hibernate.connection.username">factcan</property>
      <property name="hibernate.connection.password">factcan</property>
      <!-- property name="hibernate.connection.pool_size"></property -->

      <!-- dialect for Oracle (any version) -->
        [b]<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>[/b]

        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
        <property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
       
        <mapping resource="Infogene.hbm.xml"/>
       <mapping resource="DomainesDeValeurs.hbm.xml"/>
        <mapping resource="Xc4dvoy.hbm.xml"/>
    </session-factory>
   
</hibernate-configuration>



to I have a the good Dialect

and my code only a save
Code:

public void save(Xc4dvoyPojo pojo)
         throws HibernateException, Exception {
      Session session = null;

      // Transaction tx = null;
      try {
         session = HibernateUtil.getSessionFactory().getCurrentSession();

         session.beginTransaction();
         session.save(pojo);

         session.getTransaction().commit();

      } catch (HibernateException e) {
         session.getTransaction().rollback();
         e.printStackTrace();

         throw new ServiceException(e.getMessage(), e);

      } finally {

         HibernateUtil.getSessionFactory().close();

      }

   }


and for finish
the console

Quote:
188 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Infogene.hbm.xml
250 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: ca.canassistance.pojo.InfogenePojo -> INFOGENE
266 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : DomainesDeValeurs.hbm.xml
281 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: ca.canassistance.pojo.DomainesDeValeursPojo -> DOMAINES_DE_VALEURS
281 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Xc4dvoy.hbm.xml
297 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: ca.canassistance.pojo.Xc4dvoyPojo -> XC4DVOY
297 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
391 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
391 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
391 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
391 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: oracle.jdbc.OracleDriver at URL: jdbc:oracle:thin:@s1ora01s:1521:s1ora01i
391 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=factcan, password=****}
594 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
594 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: Oracle JDBC driver, version: 10.2.0.2.0
594 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.Oracle10gDialect
594 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
594 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
609 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
609 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
609 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
609 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
609 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
609 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
609 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
609 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
609 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
609 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
609 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
656 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
859 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
Hibernate: select ma_sequence.nextval from dual
Hibernate: insert into XC4DVOY (STT-REGISTN-NUM, STT_RECORD_TYPE, STT_SERVICE_LINE_NUM, STT_ADJUSTMENT_ACTION, STT_CLAIM_OFF_CD, STT_RELEASE_DT, STT_RELEASE_TIME, DIS_ACCOUNT_5, EMP_CERT, EMP_CONTRL, EMP_EE_SURNAME, EMP_EE_FIRST_NAME, EMP_FAMILY_OFFICE, EMP_FAMILY_NUMBER, EMP_PROVINCE_CD, EMP_LANGUAGE_CD, MEM_SURNAME, MEM_MEM_FIRST_NAME, MEM_MEM_BIRTH_DT, MEM_MEM_SEX, MEM_DEP_RELATIONSHIP, ASN_ASSGN_INDICATOR, ASN_ASSGN_PROVINCE_CD, EOB_TBL_COMMENT_CODE, CSS_SERV_DATE, CSS_SERV_TO_DT, CSS_BENEFIT_CD, CSS_BEN_SUB_CD_GROUP, CSS_NO_OF_OCCUR, CSS_PHYS_REC_CD, CSS_SERV_PROC_INFO, CSS_EXP_SUBMITTED, CSS_EXP_EXCLUDED, CSS_ELIGIBLE_EXP, CSS_DEDUCTIBLE, CSS_COINSURANCE_PERCENT, CSS_COINS_REIMBURSED, CSS_EXP_REIMBURSED, CSS_REDUCTION_FOR_MAXIMUM, CSS_REDUCTION_FOR_COB, CSS_NET_AMOUNT_REIMBURSED, CSS_EXP_LINE_NUM, CSS_DEDUCTIBLE_IND, CSS_PRV_ID, CSS_PRV_TYPE, CSS_PRV_SUB_TYPE, CSS_PRV_DISTRICT, CSS_ADJUSTMENT_ACTION, CSS_TAUX_US, STT_PLAN, STT_DEP_TYPE, STT_NO_RAMQ, STT_TYPE_CHEQUE, STT_LOCATION_CD, MSH_PROCESSOR_ID, MSH_NOM_ASSGN_CHQ, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
15725 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 917, SQLState: 42000
15725 [main] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-00917: missing comma

15725 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 917, SQLState: 42000
15725 [main] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-00917: missing comma

15725 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at ca.canassistance.model.dao.Xc4dvoyDAO.save(Xc4dvoyDAO.java:97)
at ca.canassistance.service.InClaimsServicePersistance.save(InClaimsServicePersistance.java:43)
at ca.canassistance.batch.ReclamerInClaims.chargerDonnee(ReclamerInClaims.java:107)
at ca.canassistance.batch.ReclamerInClaims.traiter(ReclamerInClaims.java:73)
at ca.canassistance.batch.ReclamerInClaims.<init>(ReclamerInClaims.java:61)
at ca.canassistance.batch.ReclamerInClaims.main(ReclamerInClaims.java:369)
Caused by: java.sql.BatchUpdateException: ORA-00917: missing comma

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10698)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 13 more



Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 3:50 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
The column name STT-REGISTN-NUM in

Code:
<property
  name="sttRegistnNum"
  column="STT-REGISTN-NUM"


is likely to cause you problems. It needs to be escaped with backticks otherwise the '-' will be interpreted as a minus in a calculation. Try:

Code:
<property
  name="sttRegistnNum"
  column="`STT-REGISTN-NUM`"


Don't know if the error message is related to this, but it is the only strange thing with the sql I can find.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.