-->
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: peculiar ClassNotFound exception
PostPosted: Mon May 11, 2009 11:30 am 
Newbie

Joined: Fri Feb 27, 2009 6:42 pm
Posts: 10
This is kind of interesting right here, running on Hibernate3

This method throws ClassNotFound exception as indicated by running YourKit (also, was the cause of a huge memory leak in our application):
Code:
   public List findlast24HoursByQueStatusName(String queStatusName) {
      Timestamp ts = new Timestamp((Calendar.getInstance().getTimeInMillis() - 86400000));
      String HQL = "select rq from RunningQue as rq where rq.startTime >='"
         + ts.toString() + "' and " +
         "rq.queStatus.queStatusName = '" + queStatusName + "'";
      return getHibernateTemplate().find(HQL);
   }


However, this does not:
Code:
   public List findlast24HoursByQueStatusName(String queStatusName) {
      Timestamp twoDays = new Timestamp(Calendar.getInstance().getTimeInMillis() - 86400000);
      
      DetachedCriteria crit = DetachedCriteria.forClass(RunningQue.class);
      crit.add(Restrictions.gt("startTime", twoDays));
      
      DetachedCriteria status = DetachedCriteria.forClass(QueStatus.class);
      status.add(Restrictions.eq("queStatusName", queStatusName));      

      crit.createCriteria("queStatus").add(Restrictions.eq("queStatusName", queStatusName));   
      return getHibernateTemplate().findByCriteria(crit);
   }


The first exception is caught somewhere however, not by our application, and the results come in fine. However, Apache likes to keep a Hashmap of notFoundResources which was killing our entire application.

Thoughts on how to remedy the issue on the HQL side of things? Coming from a company where most are familiar with SQL, using HQL seems like a more readily-readable approach so naturally preferred. Maybe I'm overlooking something silly.

-Vijal

[ Mapping File ]
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
    Mapping file autogenerated by MyEclipse persistence Tools
-->
<hibernate-mapping>
    <class name="com.crd.hibernatespring.RunningQue" table="RUNNING_QUE" schema="dbo" catalog="MSSRELENG_NEWER">
        <id name="runningQueId" type="java.lang.Integer">
            <column name="Running_Que_Id" />
            <generator class="native" />
        </id>
        <many-to-one name="buildProject" lazy = "false" class="com.crd.hibernatespring.BuildProject" fetch="select">
           <column name="Build_Project_Id" not-null="false"/>
          </many-to-one>
          <many-to-one name="buildType" lazy = "false" class="com.crd.hibernatespring.BuildType" fetch="select">
           <column name="Build_Type_Id" not-null="true"/>
          </many-to-one>
          <many-to-one name="projectType" lazy = "false" class="com.crd.hibernatespring.ProjectType" fetch="select">
            <column name="Project_Type_Id" not-null="false"/>
         </many-to-one>   
        <many-to-one name="machine" lazy="false" class="com.crd.hibernatespring.Machine" fetch="select">
            <column name="Host_Id" not-null="true" />
        </many-to-one>
        <property name="description" type="java.lang.String">
            <column name="Description" length="512" not-null="false"/>
        </property>
        <property name="Parameter" type="java.lang.String">
           <column name="Parameter" length="255" not-null="false"/>
          </property>
       
        <property name="runningId" type="java.lang.String">
            <column name="Running_Id" length="23" not-null="true" />
        </property>
        <property name="genericProjectName" type="java.lang.String">
            <column name="Generic_Project_Name" length="50" not-null="false"/>
        </property>
        <property name="lastModified" type="java.sql.Timestamp">
            <column name="Last_Modified" length="23" not-null="true" />
        </property>
        <property name="legacyResultId" type="java.lang.String">
            <column name="Legacy_Result_Id" length="15" not-null="false" />
        </property>
        <property name="release" type="java.lang.String">
            <column name="Release" length="50" not-null="false" />
        </property>
          <many-to-one name="queStatus" class="com.crd.hibernatespring.QueStatus" fetch="select" lazy="false">
           <column name="Que_Status_Id" not-null="true"/>
          </many-to-one>
        <property name="startTime" type="java.sql.Timestamp">
            <column name="StartTime" length="23" not-null="true" />
        </property>
       
        <many-to-one name="version" lazy="false" class="com.crd.hibernatespring.Version" fetch="select">
           <column name="Version_Id" not-null="true"/>
          </many-to-one>
       
       
        <set name="installBuildResults" inverse="true">
            <key>
                <column name="Running_Que_Id" />
            </key>
            <one-to-many class="com.crd.hibernatespring.InstallBuildResult" />
        </set>
        <set name="buildResults" inverse="true">
            <key>
                <column name="Running_Que_Id" />
            </key>
            <one-to-many class="com.crd.hibernatespring.BuildResult" />
        </set>
        <set name="smoketestResults" inverse="true">
            <key>
                <column name="Running_Que_Id" />
            </key>
            <one-to-many class="com.crd.hibernatespring.SmoketestResult" />
        </set>
    </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: peculiar ClassNotFound exception
PostPosted: Wed May 13, 2009 12:05 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
try "RunningQue rq" and not "RunningQue as rq"

I am just throwing this out off the top of my head but I don't think hql uses "as" to assign alias's

_________________
Please rate my replies as I need points for all of my questions also.


Top
 Profile  
 
 Post subject: Re: peculiar ClassNotFound exception
PostPosted: Wed May 13, 2009 12:17 pm 
Newbie

Joined: Fri Feb 27, 2009 6:42 pm
Posts: 10
I've tried both; the as keyword is optional according to this tutorial -- http://docs.jboss.org/hibernate/stable/ ... -from.html

Makes no difference sadly.


Top
 Profile  
 
 Post subject: Re: peculiar ClassNotFound exception
PostPosted: Thu May 14, 2009 8:58 am 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
Could you post the full exception/stack trace.

Also what is YourKit?

_________________
Please rate my replies as I need points for all of my questions also.


Top
 Profile  
 
 Post subject: Re: peculiar ClassNotFound exception
PostPosted: Thu May 14, 2009 10:09 am 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
You have to use the full class name in your hql:
Code:
from com.crd.hibernatespring.RunningQue rq where rq....

Christophe


Top
 Profile  
 
 Post subject: Re: peculiar ClassNotFound exception
PostPosted: Thu May 14, 2009 10:39 am 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
give croudet's suggestion a try as it might be something in your configuration that is making it required.

I have never known that to be required. So I would like to correct him in saying that you should not have to specify the the fully qualified name.

I don't ever use the fully qualified name myself and none of the examples in the reference use it.
http://docs.jboss.org/hibernate/stable/ ... -from.html

_________________
Please rate my replies as I need points for all of my questions also.


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.