<?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">

<!-- Hibernate mapping file for BuckoVidLib - Video
   - $Id: Video.hbm.xml,v 1.11 2015/05/14 04:58:21 dick Exp $
   -
   - BuckoVidLib - The BuckoSoft Video Library
   - Copyright(c) 2014 - Dick Balaska
   -
   - $Log: Video.hbm.xml,v $
   - Revision 1.11  2015/05/14 04:58:21  dick
   - We don't need updatedAt in VideoBase anymore. Move it to Video.
   -
   - Revision 1.10  2015/05/11 17:52:58  dick
   - Better alpha sorting. VideoBase gets a sortIndex which is derived from Video's sortTitle.
   -
   - Revision 1.9  2015/05/04 05:41:53  dick
   - VideoTexts decl moves to within Video.hbm.xml.  Just because.
   -
   - Revision 1.8  2015/05/01 12:44:52  dick
   - TVSeason does not extend Video.
   -
   - Revision 1.7  2015/04/30 03:18:03  dick
   - Deal mostly with VideoBase. Only fetch full Video when we really need it.
   - Protect all (most) calls to the restricted section of the library by session.
   -
   - Revision 1.6  2015/04/29 14:34:08  dick
   - Break up Video into base class VideoBase and Video.
   - All of the parts to define a Video are in VideoBase.
   - The idea is that I'm going to be throwing a lot of these things around, and I really don't
   - want the memory baggage of Summaries and Actor Lists, when really, I just want the
   - name of the video.
   -
   - Revision 1.5  2015/04/28 09:57:01  dick
   - Add the updatedAt field.
   -
   - Revision 1.4  2015/04/12 09:12:11  dick
   - Add the studio field.
   -
   - Revision 1.3  2015/04/02 23:52:18  dick
   - Map Actors, Writers, and Directors to the Video.
   -
   - Revision 1.2  2015/04/01 02:48:08  dick
   - Update dtd and table names are plural.
   - Map directors and genres to a video.
   -
   - Revision 1.1  2014/10/31 06:57:48  dick
   - Hibernate Video and TVShow mapping.
   -->

<hibernate-mapping>
	<class name="com.buckosoft.BuckoVidLib.domain.VideoBase" table="videos" entity-name="ShortVideo" dynamic-insert="false" dynamic-update="false">
		<id name="id" column = "videoId" >
		</id>
		<property name="hashKey" update="false" />
		<property name="section" update="false" />
	 	<property name="title" update="false" />
	 	<property name="year" update="false" />
		<property name="plexKey" update="false" />
		<property name="addedAt" />
		<property name="sortIndex" update="false" />
	</class>	

	<class name="com.buckosoft.BuckoVidLib.domain.Video" table="videos"  discriminator-value="V">
		<id name="id" column = "videoId">
			<generator class="native"/>
		</id>
		<discriminator column="ctype" type="string"/>
		<property name="hashKey" />
		<property name="section" />
	 	<property name="title" />
	 	<property name="year" />
		<property name="plexKey" />
		<property name="studio" />
		<property name="addedAt" />
		<property name="updatedAt" />
		<property name="duration" />
		<property name="sortIndex" />
		<property name="sortTitle" />
		<set name="actors" table="video_actors" lazy="false">
			<key column="videoId" />
			<many-to-many column="actorId" class="com.buckosoft.BuckoVidLib.domain.Actor"/>
		</set>
		<set name="directors" table="video_directors" lazy="false">
			<key column="videoId" />
			<many-to-many column="directorId" class="com.buckosoft.BuckoVidLib.domain.Director"/>
		</set>
		<set name="genres" table="video_genres" lazy="false">
			<key column="videoId" />
			<many-to-many column="genreId" class="com.buckosoft.BuckoVidLib.domain.Genre"/>
		</set>
		<set name="writers" table="video_writers" lazy="false">
			<key column="videoId" />
			<many-to-many column="writerId" class="com.buckosoft.BuckoVidLib.domain.Writer"/>
		</set>
		
		<subclass name="com.buckosoft.BuckoVidLib.domain.TVShow" discriminator-value="T">
		</subclass>
	</class>
	
	<class name="com.buckosoft.BuckoVidLib.domain.VideoTexts" table="videotexts">
		<id name="videoId" column = "videoId" />
		<property name="tagline" />
		<property name="summary" />
	</class>

	<class name="com.buckosoft.BuckoVidLib.domain.TVSeason" table="tvseasons">
		<id name="id" column = "seasonId">
			<generator class="native"/>
		</id>
	 	<property name="title" />
		<property name="plexKey" />
		<property name="addedAt" />
		<property name="updatedAt" />
		<property name="episodeCount" />
		<property name="videoId" />
		<property name="hashKey" />
	</class>

</hibernate-mapping>
