Hi guys,
I have problems when delete or update register. This following exception occours only when using MS SQL Server 2000.
Thank´s.
Exception and logs:
INFO Environment(<clinit>:483) - Hibernate 2.1.8
INFO Environment(<clinit>:512) - hibernate.properties not found
INFO Environment(<clinit>:543) - using CGLIB reflection optimizer
INFO Environment(<clinit>:572) - using JDK 1.4 java.sql.Timestamp handling
INFO Configuration(configure:909) - configuring from resource: /hibernate.cfg.xml
INFO Configuration(getConfigurationInputStream:881) - Configuration resource: /hibernate.cfg.xml
INFO Configuration(addResource:332) - Mapping resource: br/com/shc/tabelas/pessoa/Pessoa.hbm.xml
INFO Binder(bindRootClass:229) - Mapping class: br.com.shc.tabelas.pessoa.Pessoa -> pessoa
INFO Configuration(doConfigure:1067) - Configured SessionFactory: null
INFO Configuration(secondPassCompile:641) - processing one-to-many association mappings
INFO Configuration(secondPassCompile:650) - processing one-to-one association property references
INFO Configuration(secondPassCompile:675) - processing foreign key constraints
INFO Dialect(<init>:86) - Using dialect: net.sf.hibernate.dialect.SQLServerDialect
INFO SettingsFactory(buildSettings:74) - Use outer join fetching: true
INFO DriverManagerConnectionProvider(configure:42) - Using Hibernate built-in connection pool (not for production use!)
INFO DriverManagerConnectionProvider(configure:43) - Hibernate connection pool size: 20
INFO DriverManagerConnectionProvider(configure:77) - using driver: com.p6spy.engine.spy.P6SpyDriver at URL: jdbc:jtds:sqlserver://10.173.100.23:1433/Bilhetagem
INFO DriverManagerConnectionProvider(configure:78) - connection properties: {user=sa, password=adm}
INFO TransactionManagerLookupFactory(getTransactionManagerLookup:33) - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
INFO SettingsFactory(buildSettings:114) - Use scrollable result sets: true
INFO SettingsFactory(buildSettings:117) - Use JDBC3 getGeneratedKeys(): true
INFO SettingsFactory(buildSettings:120) - Optimize cache for minimal puts: false
INFO SettingsFactory(buildSettings:126) - echoing all SQL to stdout
INFO SettingsFactory(buildSettings:129) - Query language substitutions: {}
INFO SettingsFactory(buildSettings:140) - cache provider: net.sf.hibernate.cache.EhCacheProvider
INFO Configuration(configureCaches:1130) - instantiating and configuring caches
WARN Configurator(configure:125) - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Hibernate/hibernate-2.1/lib/ehcache-0.9.jar!/ehcache-failsafe.xml
INFO SessionFactoryImpl(<init>:119) - building session factory
INFO SessionFactoryObjectFactory(addInstance:82) - Not binding factory to JNDI, no JNDI name configured
Hibernate: select pessoa0_.id as id0_, pessoa0_.nome as nome0_ from pessoa pessoa0_ where pessoa0_.id=?
Hibernate: select id, nome from pessoa where id =?
Hibernate: update pessoa set nome=? where id=?
ERROR SessionImpl(execute:2400) - Could not synchronize database state with session
Exception in thread "main" net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:661)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:621)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2393)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at br.com.shc.teste.TestaInclusaoPessoa.main(TestaInclusaoPessoa.java:34)
===============================================
Main:
package br.com.shc.teste;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.LockMode;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.Transaction;
import net.sf.hibernate.cfg.Configuration;
import br.com.shc.tabelas.pessoa.Pessoa;
public class TestaInclusaoPessoa {
public static void main(String[] args) throws HibernateException {
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
Pessoa pessoa = new Pessoa();
pessoa = (Pessoa) session.get(Pessoa.class, new Integer(5));
pessoa.setNome("XXXX");
transaction.commit();
session.flush();
session.close();
}
}
===============================================
Mappings:
<?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>
<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="hibernate.connection.password">adm</property>
<property name="hibernate.connection.url">jdbc:jtds:sqlserver://10.173.100.23:1433/Bilhetagem</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
<!-- Print SQL to stdout. -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<mapping resource="br/com/shc/tabelas/pessoa/Pessoa.hbm.xml"/>
</session-factory>
</hibernate-configuration>
===============================================
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 25/07/2006 11:32:18 by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="br.com.shc.tabelas.pessoa.Pessoa" table="pessoa">
<id name="id" type="int" unsaved-value="0">
<column name="id"/>
<generator class="assigned"/>
</id>
<property name="nome" type="string">
<column name="nome" length="200" />
</property>
</class>
</hibernate-mapping>
===============================================
POJO:
public class Pessoa implements java.io.Serializable {
// Fields
private int id;
private String nome;
// Constructors
/** default constructor */
public Pessoa() {
}
/** minimal constructor */
public Pessoa(int id) {
this.id = id;
}
/** full constructor */
public Pessoa(int id, String nome) {
this.id = id;
this.nome = nome;
}
// Property accessors
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getNome() {
return this.nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
_________________ Paulo Nepomuceno
Java Developer
|