-->
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.  [ 6 posts ] 
Author Message
 Post subject: Bug - ClassCastException
PostPosted: Thu May 27, 2004 11:24 pm 
Newbie

Joined: Sat May 22, 2004 1:47 pm
Posts: 13
I found a bug!

java.lang.ClassCastException
at net.sf.hibernate.type.StringType.toString(StringType.java:47)
at net.sf.hibernate.type.NullableType.toString(NullableType.java:78)
at net.sf.hibernate.impl.Printer.toString(Printer.java:49)
at net.sf.hibernate.impl.Printer.toString(Printer.java:82)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2270)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2228)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at persistencia.impl.CompraDbAO.salvar(CompraDbAO.java:79)
at persistencia.impl.CompraDbAO.main(CompraDbAO.java:192)
Exception in thread "main"

My mapping:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="modelo.vo.impl.CompraImpl" table="compras">
<id name="codigo" column="codigo" type="long">
<generator class="increment"/>
</id>

<property name="codForn" type="long"/>
<property name="dataCompra" type="date"/>
<property name="dataPagto" type="date"/>
<property name="dataPedido" type="date"/>
<property name="descricao" type="string"/>
<property name="finalidade" type="string"/>
<property name="frete" type="float"/>
<property name="obs" type="string"/>
<property name="total" type="float"/>
<property name="totalICMS" type="float"/>
<property name="totalIPI" type="float"/>
</class>
</hibernate-mapping>

This is unbelievable!


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 12:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I doubt that very much.

Use your debugger.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 9:06 am 
Newbie

Joined: Sat May 22, 2004 1:47 pm
Posts: 13
I used my debugger, the exception is when cast 0(zero) value to String!


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 9:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
most likely you have an int property or something like that mapped as string. Check your mappings.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 9:10 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
So, you are using an int, but tell Hibernate to use a String and you wonder about the ClassCastException? Please read the red box before posting.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 9:35 am 
Newbie

Joined: Sat May 22, 2004 1:47 pm
Posts: 13
I


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.