Hi, I'm having trouble in a EJB app, in the id generator. Please if someone know how to help, please reply.
Regards,
Luis
Hibernate version:
2.11
Mapping documents:
PropuestaComercio.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="mx.com.prosa.bdu.dmn.mantenimiento.propuesta.PropuestaComercio"
table="TBL_BDU_PROPUESTAS_COM" lazy="true">
<id name="id">
<column name="oid" sql-type="int" not-null="true"/>
<generator class="net.sf.hibernate.id.TableHiLoGenerator">
<param name="table">TBL_BDU_IDENTIFICADORES</param>
<param name="column">ID_PROP_COMERCIO</param>
<param name="max_lo">1</param>
</generator>
</id>
<many-to-one name="status"
column="COM_ESTATU .......
...
Code between sessionFactory.openSession() and session.close():
public void crear(Object entidad) throws BDUException {
Transaction tx = null;
try {
session = PersistenceConnector.getInstance().getSession();
propCom = (PropuestaComercio) entidad;
propCom.getComercio().setPresentacion(false);
if (propCom.getComercio().getCategoriaPonderada() != null) {
if (propCom.getComercio().getCategoriaPonderada().equals(new Long(0))) {
propCom.getComercio().setCategoriaPonderada(null);
}
}
System.out.println("Categoria ponderada: " + propCom.getComercio().getCategoriaPonderada());
System.out.println(" ---- -**** ---- CECOBAN: " + propCom.getComercio().getCuenta().getCecoban());
// if (propCom.getComercio().getCadena() != null)
// System.out.println("La cadena es: ::: :::::: ::: : :: :: " + propCom.getComercio().getCadena().getOid());
tx = session.beginTransaction();
if (propCom.getComercio().getClaveRecontratacion() != null) {
System.out.println("Clave de Recontratacion: " + propCom.getComercio().getClaveRecontratacion().getId());
} else {
System.out.println("Clave de Recontratacion NULA " + propCom.getComercio().getClaveRecontratacion());
}
// guardamos el negocio nuevo...
Long a = (Long) session.save(propCom);
tx.commit();
tx = session.beginTransaction();
propCom.setId(a);
guardarDatosComercio(session, true);
tx.commit();
} catch (Exception e) {
e.printStackTrace();
if (tx != null)
try {
tx.rollback();
} catch (Exception h) {
throw new PersistenceException(h.getClass().getName(),
this.getClass().getName(),
"crear",
e.getMessage());
}
} finally {
try {
session.flush();
session.close();
} catch (HibernateException e) {
throw new PersistenceException(e.getClass().getName(), this.getClass().getName(), //this.getClass().getMethod().getName(),
"crear", e.getMessage());
}
}
}
Full stack trace of any exception that occurs:
WARNING: CORE3283: stderr: 590937 [service-j2ee-6] ERROR id.TableGenerator - could not read a hi value
WARNING: CORE3283: stderr: java.sql.SQLException: ORA-01002: fetch out of sequence
WARNING: CORE3283: stderr: at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
WARNING: CORE3283: stderr: at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
WARNING: CORE3283: stderr: at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
WARNING: CORE3283: stderr: at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
WARNING: CORE3283: stderr: at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:1198)
WARNING: CORE3283: stderr: at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2400)
WARNING: CORE3283: stderr: at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
WARNING: CORE3283: stderr: at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
WARNING: CORE3283: stderr: at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
WARNING: CORE3283: stderr: at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:93)
WARNING: CORE3283: stderr: at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
WARNING: CORE3283: stderr: at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:758)
WARNING: CORE3283: stderr: at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:731)
WARNING: CORE3283: stderr: at mx.com.prosa.bdu.eai.mantenimiento.propuesta.comercio.PropuestaComercioDAO.crear(PropuestaComercioDAO.java:230)
WARNING: CORE3283: stderr: at mx.com.prosa.bdu.dmn.mantenimiento.propuesta.PropuestaComercio.crear(PropuestaComercio.java:244)
WARNING: CORE3283: stderr: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
WARNING: CORE3283: stderr: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
WARNING: CORE3283: stderr: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
WARNING: CORE3283: stderr: at java.lang.reflect.Method.invoke(Method.java:324)
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
no sql generated
|