I'm working with Hibernate 4.2.21.Final and Oracle Database 12c 12.1.0.2.0 - 64bit Production, we have defined in our Jboss a JNDI for our DataSource, We have a strange problem in one of our Tables - only in this case, this problem it's not usual may be we have in total 2 cases during this two weeks:
When we want to save a Object in the DB, and we got this error:
Code:
2016-05-24 08:16:30,425 INFO
[org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (rommApp)
HHH000010: On release of batch it still contained JDBC statements
2016-05-24 08:16:30,427 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (rommApp) SQL
Error: 1, SQLState: 23000 2016-05-24 08:16:30,427 ERROR
[org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (rommApp)
ORA-00001: unique constraint (rommDBA.SYS_C006240) violated
This constraint it's a Primary Key, the problem seems to be we are using a primary key that it's in use, but if this fail should be fail more times, when I try to save the Object the second time works.
There is a good explanation about this random error?
Sequence:
Code:
--
-- ORDER_SEQ  (Sequence)
--
CREATE SEQUENCE rommDBA.ORDER_SEQ
  START WITH 1
  MAXVALUE 9999999999999999999999999999
  MINVALUE 1
  NOCYCLE
  NOCACHE
  ORDER
  NOKEEP
  GLOBAL;
Table:
Code:
--
-- ORDERS  (Table)
--
CREATE TABLE ROMMDBA.ORDERS
(
  ORDER_ID                 NUMBER(19)           NOT NULL,
  ORDER_NAME                VARCHAR2(255 CHAR),
  ORDER_CREATEDBY          VARCHAR2(255 CHAR)   NOT NULL,
  ORDER_CREATEDON          TIMESTAMP(6)         NOT NULL,
)
TABLESPACE ROMM
RESULT_CACHE (MODE DEFAULT)
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          1M
            NEXT             1M
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING
COMPRESS FOR OLTP
NOCACHE
NOPARALLEL
MONITORING;
Model Class:
Code:
@Id
    @SequenceGenerator(name = "OrderSequence", sequenceName = "order_seq", allocationSize=1)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="OrderSequence")    
    @Column(name = "order_id", unique = true, nullable = false)
    private Long id;
DAOImpl:
Code:
 public Order  addOrder(Order order) {
            Session session = SessionFactory.getSessionFactory().openSession();
            try {
                session.beginTransaction();
                session.save(order);
                session.getTransaction().commit();
            } catch (HibernateException e) {
                session.getTransaction().rollback();
                throw new HibernateException(e);
            } finally {
                session.close();
            }
            return order;
        }