File: /var/www/html/unitime/JavaSource/CourseOffering.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!--
* Licensed to The Apereo Foundation under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* The Apereo Foundation licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*
-->
<hibernate-mapping package="org.unitime.timetable.model">
<class name="CourseOffering" table="course_offering">
<cache include="non-lazy" usage="transactional"/>
<id
name="uniqueId"
column="uniqueid"
type="java.lang.Long">
<generator class="org.unitime.commons.hibernate.id.UniqueIdGenerator">
<param name="sequence">crs_offr_seq</param>
</generator>
</id>
<property
name="isControl"
column="is_control"
type="java.lang.Boolean"
not-null="true"/>
<property
name="permId"
column="perm_id"
type="java.lang.String"
not-null="false"
length="20"/>
<property
name="projectedDemand"
column="proj_demand"
type="java.lang.Integer"
length="5"/>
<property
name="nbrExpectedStudents"
column="nbr_expected_stdents"
type="java.lang.Integer"
length="10"
not-null="true"/>
<property
name="demand"
column="lastlike_demand"
type="java.lang.Integer"
length="10"
not-null="true"/>
<!--
<property
name="enrollment"
column="enrollment"
type="java.lang.Integer"
length="10"
not-null="false"/>
-->
<property
name="enrollment"
type="java.lang.Integer"
lazy="true"
formula="(select count(distinct e.student_id) from %SCHEMA%.student_class_enrl e where e.course_offering_id = uniqueid)"/>
<property
name="reservation"
column="reservation"
type="java.lang.Integer"
length="10"
not-null="false"/>
<property
name="subjectAreaAbbv"
type="java.lang.String"
formula=" ( select sa.subject_area_abbreviation from %SCHEMA%.subject_area sa where sa.uniqueid = subject_area_id ) "/>
<property
name="courseNbr"
column="course_nbr"
type="java.lang.String"
not-null="true"
length="40"/>
<property
name="title"
column="title"
type="java.lang.String"
not-null="false"
length="200"/>
<property
name="scheduleBookNote"
column="schedule_book_note"
type="java.lang.String"
not-null="false"
length="1000"/>
<property
name="externalUniqueId"
column="external_uid"
type="java.lang.String"
not-null="false"
length="40"/>
<property
name="uniqueIdRolledForwardFrom"
column="uid_rolled_fwd_from"
type="java.lang.Long"
not-null="false"
length="20"/>
<properties name="uniqueCourseNbr" unique="true">
<many-to-one
name="subjectArea"
class="SubjectArea"
column="subject_area_id"
insert="false"
update="false"
not-null="true"
foreign-key="fk_crs_offr_subject_area"/>
<property
name="courseNbr"
column="course_nbr"
type="java.lang.String"
not-null="true"
insert="false"
update="false"
length="10"/>
</properties>
<many-to-one
name="subjectArea"
class="SubjectArea"
column="subject_area_id"
insert="true"
update="true"
not-null="true"
foreign-key="fk_crs_offr_subject_area"/>
<many-to-one
name="instructionalOffering"
class="InstructionalOffering"
column="instr_offr_id"
not-null="true"
insert="true"
update="true"
foreign-key="fk_crs_offr_instr_offr"/>
<many-to-one
name="demandOffering"
class="CourseOffering"
column="demand_offering_id"
not-null="false"
foreign-key="fk_course_offering_demand_offr"/>
<many-to-one
name="demandOfferingType"
class="DemandOfferingType"
column="demand_offering_type"
not-null="false"/>
<many-to-one
name="courseType"
class="CourseType"
column="course_type_id"
not-null="false"
foreign-key="fk_course_offering_type"/>
<many-to-one
name="consentType"
class="OfferingConsentType"
column="consent_type"
not-null="false"
foreign-key="fk_course_consent_type"/>
<set
name="creditConfigs"
inverse="true"
lazy="true"
cascade="all-delete-orphan"
table="course_credit_unit_config">
<cache include="non-lazy" usage="transactional"/>
<key column="course_id" foreign-key="fk_crs_crdt_unit_cfg_crs_own"/>
<one-to-many class="CourseCreditUnitConfig"/>
</set>
<many-to-one
name="alternativeOffering"
class="CourseOffering"
column="alternative_offering_id"
not-null="false"
foreign-key="fk_course_offering_alternative_offr"/>
<property
name="snapshotProjectedDemand"
column="snapshot_proj_demand"
type="java.lang.Integer"
length="5"/>
<property
name="snapshotProjectedDemandDate"
column="snapshot_prj_dmd_date"
type="java.sql.Timestamp"
not-null="false"/>
<set name="disabledOverrides" table="disabled_override" lazy="true">
<cache include="non-lazy" usage="transactional"/>
<key column="course_id" foreign-key="fk_disb_override_course"/>
<many-to-many
class="OverrideType"
column="type_id"
foreign-key="fk_disb_override_type"/>
</set>
<many-to-one
name="fundingDept"
class="Department"
column="funding_dept_id"
not-null="false"
lazy="proxy"
foreign-key="fk_co_fund_dept"/>
</class>
</hibernate-mapping>