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.  [ 3 posts ] 
Author Message
 Post subject: InvocationTargetException - native generator
PostPosted: Mon Sep 13, 2004 11:07 am 
Newbie

Joined: Mon Sep 13, 2004 9:58 am
Posts: 2
Hi,

I keep getting this exception and just can't find the problem. I guess it is something to do with the generator. I tried to use the string generators and then it works fine. But as soon as I change it to the long/ bigint type (for id) I get this error. Does mysql have a problem with such ids with hibernate?

Thanx,

Assaf

Hibernate version: version 2.1.6, 9.8.2004

Mapping documents:
hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<session-factory>

<property name="connection.datasource">java:comp/env/jdbc/logistics</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<!-- Mapping files -->
<mapping resource="com/oneentry/logistics/billing/Invoice.hbm.xml"/>
<mapping resource="com/oneentry/logistics/billing/Cat.hbm.xml"/>

</session-factory>

</hibernate-configuration>

invoice.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="com.oneentry.logistics.billing.Invoice" table="invoices">

<id name="id">
<generator class="native"/>
</id>
<property name="number">
<column name="number" not-null="true"/>
</property>
<property name="spId">
<column name="sp_id" not-null="true"/>
</property>
<property name="total">
<column name="total" not-null="true"/>
</property>
<property name="subTotal">
<column name="sub_total" not-null="true"/>
</property>
<property name="vat">
<column name="vat" not-null="true"/>
</property>
<property name="created" type="timestamp">
<column name="created" not-null="true"/>
</property>
<property name="timestamp" type="timestamp">
<column name="timestamp" />
</property>

</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
SessionFactory sessionFactory =
new Configuration().configure().buildSessionFactory();

//Session session = HibernateUtil.currentSession();
Session session = sessionFactory.openSession();
Transaction tx= session.beginTransaction();

Invoice inv = new Invoice();
inv.setNumber("o4003");
inv.setSpId(5556);
inv.setTotal(22134.54);
inv.setSubTotal(11224.543);
inv.setVat(3.44);
inv.setCreated(new Date());

session.save(inv);
tx.commit();
session.refresh(inv);

HibernateUtil.closeSession();

Full stack trace of any exception that occurs:
SEVERE: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at net.sf.hibernate.util.GetGeneratedKeysHelper.prepareStatement(GetGeneratedKeysHelper.java:39)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:254)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:525)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at com.oneentry.logistics.RateAction.execute(RateAction.java:82)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at com.oneentry.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:43)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:553)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.AbstractMethodError: com.mysql.jdbc.jdbc2.Connection.prepareStatement(Ljava/lang/String;I)Ljava/sql/PreparedStatement;
at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:342)
... 57 more
Sep 13, 2004 4:13:48 PM net.sf.hibernate.impl.SessionImpl finalize
WARNING: afterTransactionCompletion() was never called
Sep 13, 2004 4:13:48 PM net.sf.hibernate.impl.SessionImpl finalize
WARNING: unclosed connection

Name and version of the database you are using:
MySql 4.0.12 standard running on red hat linux 8.

The generated SQL (show_sql=true):
Hibernate: insert into invoices (number, sp_id, total, sub_total, vat, created, timestamp) values (?, ?, ?, ?, ?, ?, ?)

Debug level Hibernate log excerpt:

Sql create (self generated)
CREATE TABLE `invoices` (
`id` bigint(20) NOT NULL auto_increment,
`number` varchar(100) NOT NULL default '',
`total` decimal(10,2) NOT NULL default '0.00',
`sub_total` decimal(10,2) NOT NULL default '0.00',
`vat` decimal(10,2) NOT NULL default '0.00',
`created` datetime NOT NULL default '0000-00-00 00:00:00',
`timestamp` timestamp(14) NOT NULL,
`sp_id` bigint(100) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM;


Top
 Profile  
 
 Post subject: found the problem
PostPosted: Thu Nov 04, 2004 10:59 am 
Newbie

Joined: Mon Sep 13, 2004 9:58 am
Posts: 2
I did not get any answer...but keeping with the spirit of OSS:

I found the problem & solution
I was using the J/connector version 2 instead of the latest 3.0.15 (mysql).

A simple upgrade solved it.


Top
 Profile  
 
 Post subject: Looking forward the solution
PostPosted: Tue Apr 25, 2006 11:09 am 
Newbie

Joined: Tue Apr 25, 2006 10:32 am
Posts: 1
I encountered exactly the same problem but can't solve it by changing the mysql driver. And I am looking forward the perfect solution.

By the way, I found another strange phenomenon: when I tried to perform save operation in a main method of a class, it works well, but in a JSP , it failed as the topic indicated.


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.