Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.5
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.siemens.swa.domain.DistributionCenterSTC"
table="DISTRIBUTION_CENTER_STC"
dynamic-update="true"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
lazy="true"
batch-size="6">
<id
name="id"
column="DISTRIBUTION_CENTER_STC_ID"
type="java.lang.Long"
>
<generator class="native"/>
</id>
<property
name="modemModelSeries"
column="MODEM_MODEL_SERIES"
not-null="true"
type="java.lang.String"
unique="true"
update="true"
insert="true"
/>
<property
name="inclusionDate"
column="INCLUSION_DATE"
not-null="true"
type="java.util.Calendar"
update="true"
insert="true"
/>
<property
name="matricula"
column="MATRICULA"
type="java.lang.String"
update="true"
insert="true"
/>
<property
name="action"
column="ACTION"
not-null="true"
type="java.lang.String"
update="true"
insert="true"
/>
<property
name="stcMovementStatus"
column="STC_MOVEMENT_STATUS"
type="java.lang.Integer"
update="true"
insert="true"
/>
<property
name="stcOperationStatus"
column="STC_OPERATION_STATUS"
type="java.lang.Integer"
update="true"
insert="true"
/>
<property
name="dateUpdated"
column="DATE_UPDATED"
type="java.util.Calendar"
update="true"
insert="true"
/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
DistributionCenterSTC stc;
Query query =
getSession().createQuery(strQuery);
query.setParameter("modemModelSeries", pnsnConcatenado);
stc =
(DistributionCenterSTC) query.uniqueResult();
if (stc != null) {
logger.debug("found!!");
}
stc.setModemModelSeries(pnsnConcatenado);
stc.setInclusionDate(dataHoraInclusao);
stc.setMatricula(matriculaDoTecnico);
stc.setAction(acao);
if (logger.isDebugEnabled()) {
logger.debug("ajustEquipament, "
+ "update vars: "
+ "ModemModelSeries: " + stc.getModemModelSeries()
+ "acao: " + stc.getAction()
+ "mat: " + stc.getMatricula());
}
getSession().flush();
Full stack trace of any exception that occurs:
na
Name and version of the database you are using:
mysql 4.1 - not using innodb
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
2006-01-27 18:18:27,545 [org.springframework.orm.hibernate3.SessionFactoryUtils] - Opening Hibernate Session
2006-01-27 18:18:27,545 [org.hibernate.impl.SessionImpl] - opened session at timestamp: 4662858168504320
2006-01-27 18:18:27,547 [org.hibernate.impl.SessionImpl] - find: SELECT dist FROM DistributionCenterSTC dist WHERE dist.modemModelSeries = :modemModelSeries
2006-01-27 18:18:27,547 [org.hibernate.engine.QueryParameters] - named parameters: {modemModelSeries=777}
2006-01-27 18:18:27,547 [org.hibernate.hql.classic.QueryTranslatorImpl] - compiling query
2006-01-27 18:18:27,556 [org.hibernate.hql.classic.QueryTranslatorImpl] - HQL: SELECT dist FROM com.siemens.swa.domain.DistributionCenterSTC dist WHERE dist.modemModelSeries = :modemModelSeries
2006-01-27 18:18:27,557 [org.hibernate.hql.classic.QueryTranslatorImpl] - SQL: select distributi0_.DISTRIBUTION_CENTER_STC_ID as DISTRIBU1_, distributi0_.MODEM_MODEL_SERIES as MODEM2_143_, distributi0_.INCLUSION_DATE as INCLUSION3_143_, distributi0_.MATRICULA as MATRICULA143_, distributi0_.ACTION as ACTION143_, distributi0_.STC_MOVEMENT_STATUS as STC6_143_, distributi0_.STC_OPERATION_STATUS as STC7_143_, distributi0_.DATE_UPDATED as DATE8_143_ from DISTRIBUTION_CENTER_STC distributi0_ where (distributi0_.MODEM_MODEL_SERIES=? )
2006-01-27 18:18:27,557 [org.hibernate.jdbc.AbstractBatcher] - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-01-27 18:18:27,557 [org.hibernate.jdbc.ConnectionManager] - opening JDBC connection
2006-01-27 18:18:27,566 [org.hibernate.SQL] - select distributi0_.DISTRIBUTION_CENTER_STC_ID as DISTRIBU1_, distributi0_.MODEM_MODEL_SERIES as MODEM2_143_, distributi0_.INCLUSION_DATE as INCLUSION3_143_, distributi0_.MATRICULA as MATRICULA143_, distributi0_.ACTION as ACTION143_, distributi0_.STC_MOVEMENT_STATUS as STC6_143_, distributi0_.STC_OPERATION_STATUS as STC7_143_, distributi0_.DATE_UPDATED as DATE8_143_ from DISTRIBUTION_CENTER_STC distributi0_ where (distributi0_.MODEM_MODEL_SERIES=? )
2006-01-27 18:18:27,566 [org.hibernate.jdbc.AbstractBatcher] - preparing statement
2006-01-27 18:18:27,566 [org.hibernate.type.StringType] - binding '777' to parameter: 1
2006-01-27 18:18:27,567 [org.hibernate.jdbc.AbstractBatcher] - about to open ResultSet (open ResultSets: 0, globally: 0)
2006-01-27 18:18:27,567 [org.hibernate.loader.Loader] - processing result set
2006-01-27 18:18:27,567 [org.hibernate.loader.Loader] - result set row: 0
2006-01-27 18:18:27,567 [org.hibernate.type.LongType] - returning '1' as column: DISTRIBU1_
2006-01-27 18:18:27,568 [org.hibernate.loader.Loader] - result row: EntityKey[com.siemens.swa.domain.DistributionCenterSTC#1]
2006-01-27 18:18:27,568 [org.hibernate.loader.Loader] - Initializing object from ResultSet: [com.siemens.swa.domain.DistributionCenterSTC#1]
2006-01-27 18:18:27,568 [org.hibernate.persister.entity.BasicEntityPersister] - Hydrating entity: [com.siemens.swa.domain.DistributionCenterSTC#1]
2006-01-27 18:18:27,568 [org.hibernate.type.StringType] - returning '777' as column: MODEM2_143_
2006-01-27 18:18:27,579 [org.hibernate.type.CalendarType] - returning '2006-01-27 19:00:28' as column: INCLUSION3_143_
2006-01-27 18:18:27,579 [org.hibernate.type.StringType] - returning null as column: MATRICULA143_
2006-01-27 18:18:27,579 [org.hibernate.type.StringType] - returning '77' as column: ACTION143_
2006-01-27 18:18:27,579 [org.hibernate.type.IntegerType] - returning null as column: STC6_143_
2006-01-27 18:18:27,579 [org.hibernate.type.IntegerType] - returning null as column: STC7_143_
2006-01-27 18:18:27,579 [org.hibernate.type.CalendarType] - returning null as column: DATE8_143_
2006-01-27 18:18:27,579 [org.hibernate.loader.Loader] - done processing result set (1 rows)
2006-01-27 18:18:27,579 [org.hibernate.jdbc.AbstractBatcher] - about to close ResultSet (open ResultSets: 1, globally: 1)
2006-01-27 18:18:27,579 [org.hibernate.jdbc.AbstractBatcher] - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-01-27 18:18:27,579 [org.hibernate.jdbc.AbstractBatcher] - closing statement
2006-01-27 18:18:27,580 [org.hibernate.loader.Loader] - total objects hydrated: 1
2006-01-27 18:18:27,580 [org.hibernate.engine.TwoPhaseLoad] - resolving associations for [com.siemens.swa.domain.DistributionCenterSTC#1]
2006-01-27 18:18:27,580 [org.hibernate.engine.TwoPhaseLoad] - done materializing entity [com.siemens.swa.domain.DistributionCenterSTC#1]
2006-01-27 18:18:27,580 [org.hibernate.engine.PersistenceContext] - initializing non-lazy collections
2006-01-27 18:18:27,580 [org.hibernate.jdbc.JDBCContext] - after autocommit
2006-01-27 18:18:27,580 [org.hibernate.impl.SessionImpl] - after transaction completion
2006-01-27 18:18:27,580 [org.springframework.orm.hibernate3.SessionFactoryUtils] - Opening Hibernate Session
2006-01-27 18:18:27,580 [org.hibernate.impl.SessionImpl] - opened session at timestamp: 4662858168647680
2006-01-27 18:18:27,585 [org.hibernate.engine.Cascades] - id unsaved-value: null
2006-01-27 18:18:27,586 [org.hibernate.event.def.AbstractSaveEventListener] - detached instance of: com.siemens.swa.domain.DistributionCenterSTC
2006-01-27 18:18:27,586 [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] - updating detached instance
2006-01-27 18:18:27,586 [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] - updating [com.siemens.swa.domain.DistributionCenterSTC#1]
2006-01-27 18:18:27,593 [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] - updating [com.siemens.swa.domain.DistributionCenterSTC#1]
2006-01-27 18:18:27,594 [org.springframework.orm.hibernate3.SessionFactoryUtils] - Opening Hibernate Session
2006-01-27 18:18:27,594 [org.hibernate.impl.SessionImpl] - opened session at timestamp: 4662858168705024
Hi all,
I can insert a row fine, but cannot update the row. This is an existing app, and everything is working fine except this one part. I've read the docs - please excuse if I missed something obvious!
My code is showing the new vars properly, and the 'gets' on the entity are showing the values have been received, but the values are not getting put in the db.
Looking at this log - my object is detached. Hmm, why is that ?
Please help.