Our DB monitoring tools registered massive spikes in Hibernate queries outside normal application hours. (e.g., 180k-240k queries per hour) Strangely, the queries regard a child container; queries for the parent don't show up on radar. Any insight to help troubleshoot, explain, or resolve this behavior would be greatly appreciated.
(Column/Package names changed to protect the innocent.)The rogue query:
Code:
select objec0_.USER_ID as USER2_1_,
objec0_.OBJECT_ID as OBJ1_1_, objec0_.OBJECT_ID as
OBJ1_3_0_, objec0_.USER_ID as USER2_3_0_,
objec0_.EVENT as EVENT3_3_0_, objec0_.PARENT as
PARENT4_3_0_, objec0_.OID as OID5_3_0_,
objec0_.LAST_UPDATED_BY as LAST6_3_0_,
objec0_.LAST_UPDATED_TIMESTAMP as LAST7_3_0_ from
OBJECT_TABLE objec0_ where
objec0_.USER_ID=:1 order by
objec0_.LAST_UPDATED_TIMESTAMP desc
The Hibernate mapping file for ObjectImpl:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="my.package.ObjectImpl" table="OBJECT_TABLE">
<id name="id" type="string" column="OBJECT_ID">
<generator class="uuid"/>
</id>
<many-to-one name="user" class = "my.package.UserImpl" column="USER_ID"/>
<property name="eventType" column="EVENT">
<type name="my.package.StringEnumUserType">
<param name="enumClassName">my.package.ObjectImpl$Event</param>
</type>
</property>
<property name="parent" type="string" column="PARENT" length="128"/>
<property name="oID" type="string" column="OID" length="128"/>
<property name="createdBy" column="LAST_UPDATED_BY" type="string" length="100"/>
<property name="createdTimestamp" column="LAST_UPDATED_TIMESTAMP" type="timestamp"/>
</class>
</hibernate-mapping>
.. and the excerpt from UserImpl that maps ObjectImpl:
Code:
<bag name="objects" cascade="all,delete-orphan" inverse="true"
order-by="LAST_UPDATED_TIMESTAMP desc">
<key column="USER_ID" not-null="true" />
<one-to-many class="my.package.ObjectImpl" />
</bag>
ObjectImpl is not handled by any (a)synchronous jobs and is rarely referenced w/in the application. Why is Hibernate so enamored w/ this object? Why is ObjectImpl queried so aggressively and not UserImpl?
Ideas to help troubleshoot/resolve this issue are greatly appreciated.