facebook

[Closed] Error Using MyEclipseHibernate, ClassCastException

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #261713 Reply

    Hi Guys:

    I have a problem with Hibernate, when i try to make a HQL query using MyEclipse(5.0 G.A), its show me the following message.

    java.lang.ClassCastException: org.hibernate.type.StringType
    at org.hibernate.tuple.PropertyFactory.buildVersionProperty(PropertyFactory.java:83)
    at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:157)
    at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
    at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
    at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:267)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:35)
    at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:70)
    at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:262)
    at com.genuitec.eclipse.hibernate.wizards.MEConsoleConfiguration.buildSessionFactory(MEConsoleConfiguration.java:209)
    at com.genuitec.eclipse.hibernate.action.MERefreshCCAction.buildSessionFactory(MERefreshCCAction.java:118)
    at com.genuitec.eclipse.hibernate.action.MEExecuteHQLAction.run(MEExecuteHQLAction.java:51)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
    at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
    at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
    at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
    at org.eclipse.core.launcher.Main.run(Main.java:977)
    at org.eclipse.core.launcher.Main.main(Main.java:952)

    #261723 Reply

    Riyad Kalla
    Member

    What version of Hibernate libraries do you have on your project where you are trying to run this HQL query?

    Also I’m assuming this project has Hibernate Capabilities added to it?

    #261737 Reply

    Haris Peco
    Member

    mepegomiabuelitoayer ,

    Can you send more details :

    – as Riyad says, what version hibernate you use
    – your mappings, POJO and HQL query

    I suppose that you have type mismatch in POJO and mappings

    Regards,

    #261790 Reply

    Hi, thanks for your support javascript:emoticon(‘:)’)
    Smile.

    support-rkalla :

    Im using Hibernate 3.1 Core Libraries and Advanced Support Libraries, I tried to run with HQL query and deployed with JBoss and i got the same exception.

    support-snpe:

    Im running the SDK 1.5, working with Postgres 8.0, postgresql-8.2dev-503.jdbc3.jar, and Im using a hibernate Reverse Engineering, im using views.

    
    <hibernate-reverse-engineering>
        <type-mapping>
            <sql-type jdbc-type="VARCHAR" hibernate-type="java.lang.String" />
            <sql-type jdbc-type="INTEGER" hibernate-type="java.lang.Long" />
            <sql-type jdbc-type="TIME" hibernate-type="java.sql.Time" />
            <sql-type jdbc-type="DATE" hibernate-type="java.util.Date" />
            <sql-type jdbc-type="NUMERIC"
                hibernate-type="java.math.BigInteger" />
            <sql-type jdbc-type="NUMERIC"
                hibernate-type="java.math.BigDecimal" scale="9" precision="2" />
        </type-mapping>
    <!-- FOR TABLES --->
           <table name="sai_actividad" schema="public"                                                                                             class="com.betomicro.sai.dto.SAIActividad">
            <primary-key>
                <generator class="native">
                    <param name="sequence">sai_actividad_id_actividad_seq</param>
                </generator>
            </primary-key>    
        </table>
    <!-- FOR VIEWS -->
    <table name="v_sac_puesto" schema="public"                     class="com.betomicro.sai.dto.VSACPuesto">
        </table>
    
    /hibernate-reverse-engineering>
    

    🙂

    I appreciate your attention,i hope this information helps to solve my problem.

    #261810 Reply

    The problem was that my database had an attribute called version, and the MyEclipse Hibernate Tool put <version> tag instead <property>.

    Bad AutoGenerated Mapping:

     <version name="version" type="java.lang.String" column="version" />

    Change To:

     <property name="version" type="java.lang.String">
                <column name="version" length="05" not-null="true" />
            </property>

    😀 Thanks for your Help.

    #261834 Reply

    Haris Peco
    Member

    mepegomiabuelitoayer ,

    You can control if MyEclipse will generate version/timestamp column on page 2 of wizard : ‘Generate version and timestamp tags’

    Regards,

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: [Closed] Error Using MyEclipseHibernate, ClassCastException

You must be logged in to post in the forum log in