These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ClassCastException et identifiant
PostPosted: Tue Nov 07, 2006 6:00 am 
Newbie

Joined: Fri Nov 03, 2006 10:12 am
Posts: 1
Bonjour,

Je ne parvient pas à insérer un tuple, une exception est levée en rapport à l'identifiant (ClassCastException: Integer).
Le schéma de la base Hypersonic a été généré par HybernateTools et la table correspondante contient bien un type INTEGER.

Merci de me donner un petit coup de main.


Hibernate version: 3.2.0.GA

Mapping :

Un objet Personne héritant d'une classe abstraite AbstractEntity.
AbstractEntity gère l'identifiant.
(Le but ici est d'avoir une table par classe concrète)

Code:
@Entity
public class Personne extends AbstractEntity implements IPersonne {

   private String nom;

   private String prenom;

   private Date dateNaissance;

   public Personne() {

   }

   public Date getDateNaissance() {
      return dateNaissance;
   }

   // .. getters et setters

}


Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class AbstractEntity implements IEntity {

   @Column
   private Integer id;

   protected AbstractEntity() {
      super();
   }

   @Id
   @GeneratedValue(strategy = GenerationType.TABLE)
   public Integer getId() {
      return id;
   }

   public void setId(Integer id) {
      this.id = id;
   }

}


Config:

Code:
<hibernate-configuration>

   <session-factory>
      <property name="show_sql">true</property>
      <property name="hibernate.connection.driver_class">
         org.hsqldb.jdbcDriver
      </property>
      <property name="hibernate.connection.url">
         jdbc:hsqldb:hsql://localhost
      </property>
      <property name="hibernate.connection.username">sa</property>
      <property name="hibernate.dialect">
         org.hibernate.dialect.HSQLDialect
      </property>
      <property name="hibernate.current_session_context_class">
         org.hibernate.context.ThreadLocalSessionContext
      </property>

      <mapping
         package="...spikeHibernate3.model.impl" />
      <mapping
         class="...spikeHibernate3.model.impl.Personne" />
      <mapping

</hibernate-configuration>


Code between sessionFactory.openSession() and session.close():

Code:
Personne aPersonne = new Personne();
...
getHibernateSession().save(aPersonne);


Logs:

...

2844 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'personneManager'
2844 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Bean with name 'personneManager' is a factory bean
2844 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking BeanPostProcessors after initialization of bean 'personneManager'
2859 [main] INFO org.springframework.jdbc.datasource.JdbcTransactionObjectSupport - JDBC 3.0 Savepoint class is available
2859 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@7ecd78]
2859 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Creating new transaction with name [ch.ne.ceg.infoplus.spikeHibernate3.manager.IPersonneManager.create]
3078 [main] DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 11628898605
3078 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@14a18d] for Hibernate transaction
3078 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@14a18d]
3094 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
3094 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
3109 [main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Bound value [org.springframework.orm.hibernate3.SessionHolder@2b7db1] for key [org.hibernate.impl.SessionFactoryImpl@148f8c8] to thread [main]
3109 [main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Initializing transaction synchronization
3109 [main] DEBUG org.springframework.transaction.interceptor.TransactionInterceptor - Getting transaction for ...spikeHibernate3.manager.IPersonneManager.create
3109 [main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@2b7db1] for key [org.hibernate.impl.SessionFactoryImpl@148f8c8] bound to thread [main]
3109 [main] DEBUG org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance
3109 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 1
3109 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - opening new JDBC connection
3172 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - created connection to: jdbc:hsqldb:hsql://localhost, Isolation Level: 1
3172 [main] DEBUG org.hibernate.SQL - select sequence_next_hi_value from hibernate_sequences where sequence_name = 'AbstractEntity'
3187 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
3187 [main] DEBUG org.hibernate.id.MultipleHiLoPerTableGenerator - new hi value: 2
3187 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 65536, using strategy: org.hibernate.id.MultipleHiLoPerTableGenerator
3187 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - saving [...spikeHibernate3.model.impl.Personne#65536]
3203 [main] DEBUG org.springframework.transaction.interceptor.RuleBasedTransactionAttribute - Applying rules to determine whether transaction should rollback on java.lang.ClassCastException: java.lang.Integer
3203 [main] DEBUG org.springframework.transaction.interceptor.RuleBasedTransactionAttribute - Winning rollback rule is: RollbackRuleAttribute with pattern [Exception]
3203 [main] DEBUG org.springframework.transaction.interceptor.TransactionInterceptor - Invoking rollback for transaction on ...infoplus.spikeHibernate3.manager.IPersonneManager.create due to throwable [java.lang.ClassCastException: java.lang.Integer]
3203 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
3203 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction rollback
3203 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Rolling back Hibernate transaction on Session [org.hibernate.impl.SessionImpl@14a18d]
3203 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion
3203 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
3203 [main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Clearing transaction synchronization
3203 [main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Removed value [org.springframework.orm.hibernate3.SessionHolder@2b7db1] for key [org.hibernate.impl.SessionFactoryImpl@148f8c8] from thread [main]
3203 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@14a18d] after transaction
3203 [main] DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils - Closing Hibernate Session
3203 [main] DEBUG org.hibernate.impl.SessionImpl - closing session
3203 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 2
3203 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion

Database:

Hypersonic 1.7.3


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.