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>