开发者

insertion in database using hibernate

I have this in my console when I insert in database, I use MySQL 5.0 and hibernate2 :

Hibernate: insert into employe 
(prenom, mail, adresse, tel, service, fonction, login, password
 , matricule, nom, id) 
  values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

net.sf.hibernate.transaction.JDBCTransaction cannot be cast to net.sf.hibernate.odmg.Transaction

any solution please

at console:

3 mai 2011 11:55:53 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.6
3 mai 2011 11:55:53 net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
3 mai 2011 11:55:53 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
3 mai 2011 11:55:53 net.sf.hibernate.cfg.Configuration configure
INFO: configuring from file: hibernate.cfg.xml
3 mai 2011 11:56:07 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: org/domain/projet/config/Employe.hbm.xml
3 mai 2011 11:56:07 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: org.domain.projet.config.Employe -> employe
3 mai 2011 11:56:07 net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
3 mai 2011 11:56:07 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
3 mai 2011 11:56:07 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
3 mai 2011 11:56:07 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
3 mai 2011 11:56:07 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect
3 mai 2011 11:56:07 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximim outer join fetch depth: 2
3 mai 2011 11:56:07 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
3 mai 2011 11:56:07 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
3 mai 2011 11:56:07 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
3 mai 2011 11:56:07 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/pfe
3 mai 2011 11:56:07 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=manel}
3 mai 2011 11:56:07 net.sf.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
3 mai 2011 11:56:07 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
3 mai 2011 11:56:07 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
3 mai 2011 11:56:07 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): true
3 mai 2011 11:56:07 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
3 mai 2011 11:56:07 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: echoing all SQL to stdout
3 mai 2011 11:56:07 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
3 mai 2011 11:56:07 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
3 mai 2011 11:56:07 net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
3 mai 2011 11:56:07 ne开发者_高级运维t.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
3 mai 2011 11:56:07 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
3 mai 2011 11:56:07 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect
3 mai 2011 11:56:07 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
3 mai 2011 11:56:07 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
3 mai 2011 11:56:07 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/pfe
3 mai 2011 11:56:07 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=manel}
3 mai 2011 11:56:07 net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: Running hbm2ddl schema update
3 mai 2011 11:56:07 net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: fetching database metadata
3 mai 2011 11:56:07 net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: updating schema
3 mai 2011 11:56:07 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
3 mai 2011 11:56:07 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
3 mai 2011 11:56:07 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
3 mai 2011 11:56:07 net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
3 mai 2011 11:56:07 net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:mysql://localhost:3306/pfe
3 mai 2011 11:56:07 net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:mysql://localhost:3306/pfe
Inserting Record
Hibernate: insert into employe (prenom, mail, adresse, tel, service, fonction, login, password, matricule, nom, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
net.sf.hibernate.transaction.JDBCTransaction cannot be cast to net.sf.hibernate.odmg.Transaction

I TRIED DIFFERENT TYPE OF TRANSACTION BUT DIDNT WORK :(


You have imported the wrong Transaction class. Check your import statements.

By the way, seriously consider upgrading to hibernate 3.x


I guess you create your transaction the wrong way. Use:

Transaction myTransaction = mySession.beginTransaction();

... where mySession is your session object you have already created.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜