[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3148) Exception thrown by debug trace code: ComponentType toLoggableString

Julien HENRY (JIRA) noreply at atlassian.com
Fri Sep 5 03:38:05 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31092#action_31092 ] 

Julien HENRY commented on HHH-3148:
-----------------------------------

Same problem for me. I get an exception each time I put hibernate in DEBUG mode.

> Exception thrown by debug trace code: ComponentType toLoggableString
> --------------------------------------------------------------------
>
>                 Key: HHH-3148
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3148
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.2.6
>         Environment: Hibernate 3.2.6.ga
> HibernateAnnotations 3.3.0.ga
> Oracle 10g Express Edition
>            Reporter: Pete Geraghty
>            Priority: Minor
>         Attachments: ToLoggableStringExample.txt
>
>
> The method toLoggableString in ComponentType is used to provide tracing output when running with log level DEBUG.  In some circumstances it throws a ClassCastException.
> This is not a good idea in tracing code and obscures underlying problems.
> In my case the underlying problem was a previous incorrect call to set a parameter value in a query. I saw that previous JIRA issues have mentioned this ClassCastException as a side effect of other underlying problems - it is a distraction and time-waster.
> Lines 375-378 read:
> 		EntityMode entityMode = tuplizerMapping.guessEntityMode( value );
> 		if ( entityMode == null ) {
> 			throw new ClassCastException( value.getClass().getName() );
> 		}
> A better solution would be to just us String.valueOf
> 		EntityMode entityMode = tuplizerMapping.guessEntityMode( value );
> 		if ( entityMode == null ) {
> 			return String.valueOf(value);
> 		}
> Another possibility would be to concatenate some diagnostic message with String.valueOf, but personally I don't think that be helpful.
> Stack trace is:
> Exception in thread "main" java.lang.ClassCastException: java.lang.String
> 	at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:377)
> 	at org.hibernate.pretty.Printer.toString(Printer.java:76)
> 	at org.hibernate.engine.QueryParameters.traceParameters(QueryParameters.java:277)
> 	at org.hibernate.engine.query.HQLQueryPlan.performIterate(HQLQueryPlan.java:210)
> 	at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1192)
> 	at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:46)
> 	at hib.example.EntityWithEmbeddable.main(EntityWithEmbeddable.java:44)
> Example code for the classes and schema to reproduce is pasted into the attachment.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list