Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
2.1.8
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.skillsoft.ilt.beans">
<class name="Session" table="iltSession">
<id name="ID" column="ID" unsaved-value="0">
<generator class="native"/>
</id>
<property name="number" column="number"/>
<property name="notes" column="notes"/>
<property name="timeZoneID" column="tzid"/>
<property name="statusCode" column="status"/>
<property name="capacity" column="capacity"/>
<property name="closingDays" column="closingDays"/>
<property name="instructorPrivileged" column="instructorPrivileged"/>
<property name="sessionApprovalRequired" column="sessionApprovalRequired"/>
<property name="approvalRequired" column="approvalRequired"/>
<property name="enrolled"/>
<property name="waiting"/>
<property name="percentFull"/>
<many-to-one name="instructor" class="User" column="instructor"/>
<many-to-one name="ownedBy" class="User" column="sessionOwner"/>
<many-to-one name="sessionApprover" class="User" column="sessionApprover"/>
<many-to-one name="course" class="Course" column="course"/>
<many-to-one name="facility" class="Facility" column="facility"/>
<many-to-one name="classroom" class="Classroom" column="classroom"/>
<many-to-one name="owner" column="owner" class="Contact"/>
<!-- dialogue -->
<one-to-one name="dialogInfo" class="DialogSession" cascade="all" />
<!-- bag => Collection, unordered, allows duplicates -->
<bag
name="roster"
table="iltRegistration"
inverse="true"
cascade="all-delete-orphan"
lazy="true"
outer-join="false"
batch-size="100">
<key column="session"/>
<one-to-many class="Registration"/>
</bag>
<!-- bag => Collection, unordered, allows duplicates -->
<bag
name="schedule"
table="iltScheduleinfo"
inverse="true"
order-by="startTime"
cascade="all-delete-orphan"
lazy="false"
outer-join="false"
batch-size="100">
<key column="session"/>
<one-to-many class="Schedule"/>
</bag>
<!-- bag => Collection, unordered, allows duplicates -->
<bag
name="attrValues"
table="iltExtAttrSession"
inverse="true"
lazy="false"
cascade="all-delete-orphan"
outer-join="false"
batch-size="100">
<key column="sessionid"/>
<many-to-many class="ExtAttrSession" column="valueid"/>
</bag>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
SQL Server 2000 SP4
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
I would like to generate the data needed for the Session properties enrolled, waiting, and percentFull when I load the data. I know the SQL I want to run, but I'm uncertain how to configure this. I see there is an option to generate properties on SQL insert or update. I would really like to know how to generate these on load. I'm referencing data in another table (iltRegistration) to generate this data.
(SELECT COUNT(iltRegistration.ID)
FROM iltRegistration
WHERE iltRegistration.session = iltSession.ID
AND iltRegistration.status != 400 AND iltRegistration.status != 300) enrolled
(SELECT COUNT(iltRegistration.ID)
FROM iltRegistration
WHERE iltRegistration.session = iltSession.ID
AND iltRegistration.status = 400) waiting
percentFull =
CASE iltSession.capacity
WHEN 0 THEN 0.0
ELSE
((CAST(enrolled AS FLOAT) + CAST(waiting AS FLOAT)) / CAST(iltSession.capacity AS FLOAT))
END