Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.05
Code between sessionFactory.openSession() and session.close():
SchedaUtenza suHib = null;
if(checkConcurrency) {
String codTecnicoScheda = su.getCodTecnicoSchedaUtenza();
suHib = (SchedaUtenza) getHibernateTemplate().get(SchedaUtenza.class, codTecnicoScheda);
if( (suHib.getDataModificaRecord() == null) ||
(suHib.getDataModificaRecord().equals(su.getDataModificaRecord())) )
update = true;
else {
String msg = "Aggiornamento non eseguito. Il dato e' gia' stato modificato da un altro utente.";
throw new Exception(msg);
}
}
else {
update = true;
}
if(update) {
su.setDataModificaRecord(new Date());
suHib = (SchedaUtenza) getHibernateTemplate().merge(su);
}
Full stack trace of any exception that occurs:
ERROR [main] - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.JDBCException.<init>(JDBCException.java:26)
at org.hibernate.exception.GenericJDBCException.<init>(GenericJDBCException.java:19)
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:74)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:69)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:150)
.......
Name and version of the database you are using: Oracle 9
The generated SQL (show_sql=true):
Hibernate: select schedauten0_.COD_TECNICO_SCHEDA_UTENZA as COD1_0_, schedauten0_.DATA_CREAZIONE_RECORD as DATA2_23_0_, schedauten0_.UTENTE_CREAZIONE_RECORD as UTENTE3_23_0_, schedauten0_.DATA_MODIFICA_RECORD as DATA4_23_0_, schedauten0_.UTENTE_MODIFICA_RECORD as UTENTE5_23_0_, schedauten0_.CODICE_CLIENTE_DISTR_ORIGINALE as CODICE6_23_0_, schedauten0_.DESCRIZIONE_SCHEDA_UTENZA as DESCRIZI7_23_0_, schedauten0_.NOTE as NOTE23_0_, schedauten0_.COD_ENTE as COD9_23_0_, schedauten0_.COD_COSTANTE as COD10_23_0_ from DS_SCHEDE_UTENZE schedauten0_ where schedauten0_.COD_TECNICO_SCHEDA_UTENZA=?
Hibernate: select ente0_.COD_ENTE as COD1_0_, ente0_.DATA_MODIFICA_RECORD as DATA2_17_0_, ente0_.UTENTE_MODIFICA_RECORD as UTENTE3_17_0_, ente0_.DES_ENTE as DES4_17_0_, ente0_.COD_CONTROPARTE as COD5_17_0_, ente0_.COD_TIPO_VALUTA as COD6_17_0_, ente0_.COD_GRUPPO_ENTE as COD7_17_0_, ente0_.SOGGETTO_A_IVA as SOGGETTO8_17_0_, ente0_.COEFF_VALUTAZIONE as COEFF9_17_0_ from DS_ENTI ente0_ where ente0_.COD_ENTE=?
Hibernate: select costantemo0_.COD_COSTANTE as COD1_0_, costantemo0_.DATA_MODIFICA_RECORD as DATA2_21_0_, costantemo0_.UTENTE_MODIFICA_RECORD as UTENTE3_21_0_, costantemo0_.DES_COSTANTE as DES4_21_0_, costantemo0_.COD_TIPO_COSTANTE as COD5_21_0_, costantemo0_.FATTORE_CONVERSIONE_1 as FATTORE6_21_0_, costantemo0_.FATTORE_CONVERSIONE_2 as FATTORE7_21_0_, costantemo0_.COD_UNITA_MISURA as COD8_21_0_ from DS_COSTANTI_MODULI_ENERGETICI costantemo0_ where costantemo0_.COD_COSTANTE=?
Hibernate: select unitamisur0_.COD_UNITA_MISURA as COD1_0_, unitamisur0_.DATA_MODIFICA_RECORD as DATA2_19_0_, unitamisur0_.UTENTE_MODIFICA_RECORD as UTENTE3_19_0_, unitamisur0_.DES_UNITA_MISURA as DES4_19_0_ from DS_UNITA_MISURA unitamisur0_ where unitamisur0_.COD_UNITA_MISURA=?
Hibernate: update DS_SCHEDE_UTENZE set DATA_CREAZIONE_RECORD=?, UTENTE_CREAZIONE_RECORD=?, DATA_MODIFICA_RECORD=?, UTENTE_MODIFICA_RECORD=?, CODICE_CLIENTE_DISTR_ORIGINALE=?, DESCRIZIONE_SCHEDA_UTENZA=?, NOTE=?, COD_ENTE=?, COD_COSTANTE=? where COD_TECNICO_SCHEDA_UTENZA=?
Hibernate: update DS_DISTRIBUTORI_UTENZE set COD_TECNICO_SCHEDA_UTENZA=null where COD_TECNICO_SCHEDA_UTENZA=?
ERROR [main] - ORA-01407: impossibile aggiornare ("DATASOFTWARE"."DS_DISTRIBUTORI_UTENZE"."COD_TECNICO_SCHEDA_UTENZA") a NULL
ERROR [main] - ORA-01407: impossibile aggiornare ("DATASOFTWARE"."DS_DISTRIBUTORI_UTENZE"."COD_TECNICO_SCHEDA_UTENZA") a NULL
This is the excerpt of my mapping file:
<hibernate-mapping default-cascade="none">
<class name="com.datasw.gdp2000web.model.utenze.bo.SchedaUtenza" table="DS_SCHEDE_UTENZE">
<id name="codTecnicoSchedaUtenza" type="string" column="COD_TECNICO_SCHEDA_UTENZA"/>
<property name="dataCreazioneRecord" type="timestamp" column="DATA_CREAZIONE_RECORD"/>
<property name="utenteCreazioneRecord" type="string" column="UTENTE_CREAZIONE_RECORD"/>
<property name="dataModificaRecord" type="timestamp" column="DATA_MODIFICA_RECORD"/>
<set name="distributoreUtenza" lazy="true" cascade="none">
<key column="COD_TECNICO_SCHEDA_UTENZA"/>
<one-to-many class="com.datasw.gdp2000web.model.utenze.bo.DistributoreUtenza"/>
</set>
...
Although cascade="none" is the default I have showed it but Hibernate try to update the child object.
The Hibernate reference document says:
"You may even use cascade="all" to specify that all operations should be cascaded along the association. The
default cascade="none" specifies that no operations are to be cascaded."
How can i solve my problem?