Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I have a strange casting problem that I've beat my head on for days and cannot seem to figure out. Below is my test case and code postings. The issue is when trying to cast from LOCATION to ShortTimeLocation, as you'll discover in the error message. These objects inherit from one another using the table-per-class pattern. The database is a legacy database, not very well normalized, and I thus CANNOT change the database structure. So I built the object data model to fit the relational data model as best I could. No matter what I do, I cannot seem to satify NHibernate so that it will handle the casting correctly. I expected it not to be a problem as per rules of polymorphism, since the objects directly related via inheritence. Am I missing something?
[UPDATE:] I should mention also for clarity, that the code in the test case is attempting to do a QBE via the ICriteria facility in NHibernate. It fails during the ICriteria.List<LongCrash>() call.
However, if the test case PASSED when I did the HQL route using IQuery. For example, this code FAILS:
Code:
IList<LongCrash> results = criteria.List<LongCrash>();
But this code SUCCEEDS:
Code:
NHibernate.IQuery query = session.CreateQuery( "select c from Crash as c" );
Thanks in advance for your help, guys.
Hibernate version: NHibernate 1.2.0.1001 (1.2.0.Alpha1)
Below are my POCOs. Note that I used NHibernate.Mapping.Attributes. Also note that I'm using proxies and interfaces to provide some abstraction from the ugly legacy relational data model. Specifically, observe how I set up the ILocation, LOCATION, and ShortTimeLocation objects since they are the ones giving me the problems.
Code:
public delegate void ObjectChangingEventHandler( object sender, System.EventArgs args );
public interface IObjectState : System.ComponentModel.INotifyPropertyChanged {
bool Dirty {
get;
}
}
public abstract partial class ObjectState : IObjectState {
private bool _dirty = false;
public virtual event ObjectChangingEventHandler ObjectChanging;
public virtual event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
public bool Dirty {
get {
return _dirty;
}
protected set {
if ( _dirty != value ) {
_dirty = value;
}
}
}
#region Methods
protected virtual void OnChanging() {
if ( ( this.ObjectChanging != null ) ) {
this.ObjectChanging( this, System.EventArgs.Empty );
}
}
protected virtual void OnChanging( string property ) {
if ( ( this.ObjectChanging != null ) ) {
this.ObjectChanging( this, System.EventArgs.Empty );
}
}
protected virtual void OnChanged( string property ) {
Dirty = true;
if ( this.PropertyChanged != null ) {
this.PropertyChanged( this, new System.ComponentModel.PropertyChangedEventArgs( property ) );
}
}
protected virtual void OnChanged() {
Dirty = true;
if ( this.PropertyChanged != null ) {
this.PropertyChanged( this, (System.ComponentModel.PropertyChangedEventArgs) System.ComponentModel.PropertyChangedEventArgs.Empty );
//this.PropertyChanged( this, new System.ComponentModel.PropertyChangedEventArgs( "<Not Reported>" ) );
}
}
#endregion
}
public interface IProduct : IObjectState {
string CaseNumber {
get;
set;
}
string Id {
get;
set;
}
string ProductName {
get;
set;
}
}
public interface ICrash : IProduct {
IContributingCauses ContributingCauses {
get;
set;
}
ILocation Location {
get;
set;
}
IVehiclePedestrian VehiclePedestrians {
get;
set;
}
}
public interface ILocation : IObjectState {
string Id {
get;
set;
}
string Latitude {
get;
set;
}
string Longitude {
get;
set;
}
}
public interface IContributingCauses : IObjectState {
string CauseEnvironment1 {
get;
set;
}
string Id {
get;
set;
}
}
public interface IVehiclePedestrian : IObjectState {
string EstDamage1 {
get;
set;
}
string Id {
get;
set;
}
IProduct Product {
get;
set;
}
}
[Class( NameType = typeof( ProductHeader ), Polymorphism = PolymorphismType.Explicit, ProxyType = typeof( IProduct )
, Table = "`Prd_Header`", Mutable = false, Lazy = false
, DynamicUpdate = false, DynamicInsert = false )]
public partial class ProductHeader : ObjectState, IProduct {
#region Fields
private string _id;
private string _caseNumber;
private string _productName;
#endregion
#region Ctors
public ProductHeader() {
}
#endregion
#region Properties
[Id( 0, Name = "Id", Length = 100, Access = "property", TypeType = typeof( string ) )]
[Column( 1, Name = "`PrdKey`", Length = 100, Unique = true, NotNull = true )]
[Generator( 2, Class = "native" )]
public virtual string Id {
get {
return this._id;
}
set {
this._id = value;
}
}
#region Other Properties
[Property( Name = "CaseNumber", Column = "`CaseNumber`"
, Access = "property", NotNull = false
, TypeType = typeof( string ), Insert = false, Update = false )]
public virtual string CaseNumber {
get {
return this._caseNumber;
}
set {
this._caseNumber = value;
}
}
[Discriminator( 0, Column = "`PrdName`" )]
[Property( 1, Name = "ProductName", Column = "`PrdName`", Length = 100, Access = "property"
, TypeType = typeof( string ), Insert = false, Update = false )]
public virtual string ProductName {
get {
return this._productName;
}
set {
this._productName = value;
}
}
#endregion
#endregion
#region Methods
public override string ToString() {
return this.CaseNumber != null ? this.CaseNumber.ToString() : "<null>";
}
#endregion
}
[Subclass( DiscriminatorValue = "base", NameType = typeof( Crash ), ExtendsType = typeof( ProductHeader )
, ProxyType = typeof( ICrash ), Lazy = false
, DynamicUpdate = false, DynamicInsert = false )]
public partial class Crash : ProductHeader, ICrash, IProduct {
#region Fields
[b]private ILocation _location =new LOCATION();[/b]
private IContributingCauses _contributingCauses =new ContributingCauses();
private IVehiclePedestrian _vehiclePedestrians =new VehiclePedestrian();
#endregion
#region Ctors
public Crash() {
}
#endregion
#region Properties
public virtual ILocation Location {
get {
return _location;
}
set {
if ( _location != value ) {
OnChanging( "Location" );
_location = value;
OnChanged( "Location" );
}
}
}
public virtual IContributingCauses ContributingCauses {
get {
return _contributingCauses;
}
set {
_contributingCauses = value;
}
}
public virtual IVehiclePedestrian VehiclePedestrians {
get {
return _vehiclePedestrians;
}
set {
_vehiclePedestrians = value;
}
}
#endregion
}
public partial class ContributingCauses : ObjectState, IContributingCauses {
#region Fields
private string _id;
private string _CauseEnvironment1;
private IProduct _product =new ProductHeader();
#endregion
#region Ctors
public ContributingCauses() {
}
#endregion
#region Properties
public virtual string Id {
get {
return _id;
}
set {
_id = value;
}
}
public virtual IProduct Product {
get {
return _product;
}
set {
_product = value;
}
}
public virtual string CauseEnvironment1 {
get {
return this._CauseEnvironment1;
}
set {
if ( ( this._CauseEnvironment1 != value ) ) {
this.OnChanging();
this._CauseEnvironment1 = value;
this.OnChanged( @"CauseEnvironment1" );
}
}
}
#endregion
#region Methods
public override string ToString() {
return this._id != null ? this._id.ToString() : "";
}
#endregion
}
public partial class VehiclePedestrian : ObjectState, IVehiclePedestrian {
#region Fields
private string _id;
private string _EstDamage1;
private IProduct _product =new ProductHeader();
#endregion
#region Ctors
public VehiclePedestrian() {
}
#endregion
#region Properties
public virtual string Id {
get {
return _id;
}
set {
_id = value;
}
}
public virtual IProduct Product {
get {
return _product;
}
set {
_product = value;
}
}
public virtual string EstDamage1 {
get {
return this._EstDamage1;
}
set {
if ( ( this._EstDamage1 != value ) ) {
this.OnChanging();
this._EstDamage1 = value;
this.OnChanged( "EstDamage1" );
}
}
}
#endregion
#region Methods
public override string ToString() {
return this._id != null ? this._id.ToString() : "";
}
#endregion
}
[Subclass( DiscriminatorValue = "CRASH-LONG", NameType = typeof( LongCrash ), ProxyType = typeof( ICrash )
, ExtendsType = typeof( Crash ), Lazy = false, DynamicUpdate = false, DynamicInsert = false )]
public partial class LongCrash : Crash, ICrash, IProduct {
#region Fields
private LongPaperPassenger _passengers =new LongPaperPassenger();
private LongPaperWitnesses _witnesses =new LongPaperWitnesses();
#endregion
#region Ctors
public LongCrash() {
}
#endregion
#region Properties
[Id( 0, Name = "Id", TypeType = typeof( string ), Length = 100 )]
[Column( 1, Name = "`PrdKey`", NotNull = false, Unique = true, Length = 100 )]
[Generator( 2, Class = "native" )]
public new virtual string Id {
get {
return base.Id;
}
set {
base.Id = value;
}
}
OneToOne( 1, Name = "Location", ClassType = typeof( LongPaperTimeLocation ), PropertyRef = "Product"
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto, Cascade = CascadeStyle.None )]
public new virtual ILocation Location {
get {
return base.Location;
}
set {
if ( base.Location != value ) {
OnChanging( "Location" );
base.Location = value;
OnChanged( "Location" );
}
}
}
[OneToOne( 1, Name = "ContributingCauses", ClassType = typeof( LongPaperContributingCauses ), PropertyRef = "Product"
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto, Cascade = CascadeStyle.None )]
public override IContributingCauses ContributingCauses {
get {
return base.ContributingCauses;
}
set {
base.ContributingCauses = value;
}
}
[OneToOne( 1, Name = "VehiclePedestrians", ClassType = typeof( LongPaperVehiclePedestrian ), PropertyRef = "Product"
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto, Cascade = CascadeStyle.None )]
public override IVehiclePedestrian VehiclePedestrians {
get {
return base.VehiclePedestrians;
}
set {
base.VehiclePedestrians = value;
}
}
[OneToOne( 1, Name = "Passengers", ClassType = typeof( LongPaperPassenger ), PropertyRef = "Product"
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto, Cascade = CascadeStyle.None )]
public virtual LongPaperPassenger Passengers {
get {
return _passengers;
}
set {
_passengers = value;
}
}
[OneToOne( 1, Name = "Witnesses", ClassType = typeof( LongPaperWitnesses ), PropertyRef = "Product"
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto, Cascade = CascadeStyle.None )]
public virtual LongPaperWitnesses Witnesses {
get {
return _witnesses;
}
set {
_witnesses = value;
}
}
#endregion
#region Methods
public override string ToString() {
return base.ToString();
}
#endregion
}
[Subclass( DiscriminatorValue = "ShortCrash", NameType = typeof( ShortCrash ), ProxyType = typeof( ICrash )
, ExtendsType = typeof( Crash ), Lazy = false, DynamicUpdate = false, DynamicInsert = false )]
public partial class ShortCrash : Crash, ICrash, IProduct {
#region Ctors
public ShortCrash() {
}
#endregion
#region Properties
[Id( 0, Name = "Id", Length = 100, TypeType = typeof( string ) )]
[Column( 1, Name = "`PrdKey`", NotNull = false, Unique = true, Length = 100 )]
[Generator( 2, Class = "native" )]
public new virtual string Id {
get {
return base.Id;
}
set {
base.Id = value;
}
}
[OneToOne( 1, Name = "Location", ClassType = typeof( LongPaperTimeLocation ), PropertyRef = "Product"
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto, Cascade = CascadeStyle.None )]
public new virtual ILocation Location {
get {
return base.Location;
}
set {
if ( base.Location != value ) {
OnChanging( "Location" );
base.Location = value;
OnChanged( "Location" );
}
}
}
[OneToOne( 1, Name = "ContributingCauses", ClassType = typeof( ShortContributingCauses ), PropertyRef = "Product"
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto, Cascade = CascadeStyle.None )]
public override IContributingCauses ContributingCauses {
get {
return base.ContributingCauses;
}
set {
base.ContributingCauses = value;
}
}
[OneToOne( 1, Name = "VehiclePedestrians", ClassType = typeof( ShortVehiclePedestrian ), PropertyRef = "Product"
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto, Cascade = CascadeStyle.None )]
public override IVehiclePedestrian VehiclePedestrians {
get {
return base.VehiclePedestrians;
}
set {
base.VehiclePedestrians = value;
}
}
#endregion
}
[Class( DiscriminatorValue = "LOCATION", NameType = typeof( LOCATION ), ProxyType = typeof( ILocation ), Table = "`LOCATION`"
, Polymorphism = PolymorphismType.Explicit, Mutable = false, Lazy = false
, DynamicUpdate = false, DynamicInsert = false )]
public partial class LOCATION : ObjectState, ILocation {
#region Fields
private string _id;
private string _Latitude;
private string _Longitude;
#endregion
#region Ctors
public LOCATION() {
}
#endregion
#region Properties
[Id( 1, Name = "Id", Length = 100, Access = "property", TypeType = typeof( string ) )]
[Column( 2, Name = "`COLLKEY`", Length = 100, Unique = true )]
[Generator( 3, Class = "native" )]
public virtual string Id {
get {
return this._id;
}
set {
if ( ( this._id != value ) ) {
this.OnChanging();
this._id = value;
this.OnChanged( "Id" );
}
}
}
#region Other Properties
[Property( Name = "Latitude", Column = "`Latitude`", Access = "property", NotNull = false
, TypeType = typeof( string ), Insert = false, Update = false )]
public virtual string Latitude {
get {
return this._Latitude;
}
set {
if ( ( this._Latitude != value ) ) {
this.OnChanging();
this._Latitude = value;
this.OnChanged( "Latitude" );
}
}
}
[Property( Name = "Longitude", Column = "`Longitude`", Access = "property", NotNull = false
, TypeType = typeof( string ), Insert = false, Update = false )]
public virtual string Longitude {
get {
return this._Longitude;
}
set {
if ( ( this._Longitude != value ) ) {
this.OnChanging();
this._Longitude = value;
this.OnChanged( "Longitude" );
}
}
}
#endregion
#endregion
#region Methods
public override string ToString() {
return this.CityTown != null ? this.CityTown.ToString() : "<null>";
}
#endregion
}
[JoinedSubclass( NameType = typeof( LongPaperTimeLocation ), ExtendsType = typeof( LOCATION ), ProxyType = typeof( ILocation )
, Table = "`LongPaperTimeLocation`", Lazy = false, DynamicUpdate = false, DynamicInsert = false )]
public partial class LongPaperTimeLocation : LOCATION, ILocation {
#region Fields
private string _agencyReportNumber;
private IProduct _product =new ProductHeader();
#endregion
#region Ctors
public LongPaperTimeLocation() {
}
#endregion
#region Properties
[Key( 0, Column = "`LocationColKey`" )]
[Generator( 1, Class = "native" )]
public override string Id {
get {
return base.Id;
}
set {
base.Id = value;
}
}
[ManyToOne( 1, Name = "Product", ClassType = typeof( LongCrash ), Column = "`PrdKey`", Unique = true
, Update = false, Insert = false, Cascade = CascadeStyle.None
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto, NotNull = true )]
public virtual IProduct Product {
get {
return this._product;
}
set {
this._product = value;
}
}
#region Other Properties
[Property( Name = "AgencyReportNumber", Formula = "`AgencyReportNumbert`", TypeType = typeof( string ), Insert = false, Update = false
, Access = "property", NotNull = false )]
public virtual string AgencyReportNumber {
get {
return this._agencyReportNumber;
}
set {
this._agencyReportNumber = value;
}
}
#endregion
#endregion
#region Methods
public override string ToString() {
return base.ToString();
}
#endregion
}
[Class( NameType = typeof( LongPaperContributingCauses ), ProxyType = typeof( IContributingCauses ), Table = "`LongPaperContributingCauses`"
, Polymorphism = PolymorphismType.Explicit, Mutable = false, Lazy = false
, DynamicUpdate = false, DynamicInsert = false, OptimisticLock = OptimisticLockMode.None )]
public partial class LongPaperContributingCauses : ContributingCauses, IContributingCauses {
#region Ctors
public LongPaperContributingCauses() {
}
#endregion
#region Properties
[Id( 0, Name = "Id", Length = 100, Access = "property", TypeType = typeof( string ) )]
[Column( 1, Name = "`PrdKey`", Length = 100, Unique = true, NotNull = true )]
[Generator( 2, Class = "native" )]
public override string Id {
get {
return base.Id;
}
set {
base.Id = value;
}
}
[ManyToOne( 1, Name = "Product", ClassType = typeof( LongCrash ), Column = "`PrdKey`", Unique = true
, Update = false, Insert = false, Cascade = CascadeStyle.None
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto, NotNull = true )]
public override IProduct Product {
get {
return base.Product;
}
set {
base.Product = value;
}
}
#region Other Properties
[Property( Name = "CauseEnvironment1", Formula = "`CauseEnvironment1`", Access = "property"
, TypeType = typeof( string ), Insert = false, Update = false )]
public override string CauseEnvironment1 {
get {
return base.CauseEnvironment1;
}
set {
if ( ( base.CauseEnvironment1 != value ) ) {
base.CauseEnvironment1 = value;
}
}
}
#endregion
#endregion
#region Methods
public override string ToString() {
return Id != null ? Id.ToString() : "<null>";
}
#endregion
}
[Class( NameType = typeof( LongPaperVehiclePedestrian ), ProxyType = typeof( IVehiclePedestrian ), Table = "`LongPaperVehiclePedestrian`"
, Polymorphism = PolymorphismType.Explicit, Mutable = false, Lazy = false
, DynamicUpdate = false, DynamicInsert = false, OptimisticLock = OptimisticLockMode.None )]
public partial class LongPaperVehiclePedestrian : VehiclePedestrian, IVehiclePedestrian {
#region Fields
private string _LicState;
#endregion
#region Ctors
public LongPaperVehiclePedestrian() {
}
#endregion
#region Properties
[Id( 0, Name = "Id", Length = 100, Access = "property", TypeType = typeof( string ) )]
[Column( 1, Name = "`PrdKey`", Length = 100, Unique = true, NotNull = true )]
[Generator( 2, Class = "native" )]
public override string Id {
get {
return base.Id;
}
set {
base.Id = value;
}
}
[ManyToOne( 1, Name = "Product", ClassType = typeof( LongCrash ), Column = "`PrdKey`", Unique = true, NotNull = true
, Update = false, Insert = false, Cascade = CascadeStyle.None
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto )]
public override IProduct Product {
get {
return base.Product;
}
set {
base.Product = value;
}
}
#region Other Properties
[Property( Name = "LicState", Formula = "`LicState`", Access = "property"
, TypeType = typeof( string ), Insert = false, Update = false )]
public virtual string LicState {
get {
return this._LicState;
}
set {
if ( ( this._LicState != value ) ) {
this._LicState = value;
}
}
}
[Property( Name = "EstDamage1", Formula = "`EstDamage1`", Access = "property"
, TypeType = typeof( string ), Insert = false, Update = false )]
public override string EstDamage1 {
get {
return base.EstDamage1;
}
set {
if ( ( base.EstDamage1 != value ) ) {
base.EstDamage1 = value;
}
}
}
#endregion
#endregion
#region Methods
public override string ToString() {
return Id != null ? Id.ToString() : "<null>";
}
#endregion
}
[Class( NameType = typeof( LongPaperPassenger ), Table = "`LongPaperPassengers`"
, Polymorphism = PolymorphismType.Explicit, Mutable = false, Lazy = false
, DynamicUpdate = false, DynamicInsert = false, OptimisticLock = OptimisticLockMode.None )]
public partial class LongPaperPassenger : ObjectState {
#region Fields
private string _id;
private string _PassengerName1;
private IProduct _product =new ProductHeader();
#endregion
#region Ctors
public LongPaperPassenger() {
}
#endregion
#region Properties
[Id( 0, Name = "Id", Length = 100, Access = "property", TypeType = typeof( string ) )]
[Column( 1, Name = "`PrdKey`", Length = 100, Unique = true )]
[Generator( 2, Class = "native" )]
public virtual string Id {
get {
return _id;
}
set {
_id = value;
}
}
[ManyToOne( 1, Name = "Product", ClassType = typeof( LongCrash ), Column = "`PrdKey`", Unique = true, NotNull = true
, Update = false, Insert = false, Cascade = CascadeStyle.None
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto )]
public virtual IProduct Product {
get {
return this._product;
}
set {
_product = value;
}
}
#region Other Properties
[Property( Name = "PassengerName1", Column = "`PassengerName1`", Access = "property"
, TypeType = typeof( string ), Insert = false, Update = false )]
public virtual string PassengerName1 {
get {
return this._PassengerName1;
}
set {
if ( ( this._PassengerName1 != value ) ) {
this.OnChanging();
this._PassengerName1 = value;
this.OnChanged();
}
}
}
#endregion
#endregion
#region Methods
public override string ToString() {
return Id != null ? Id.ToString() : "<null>";
}
#endregion
}
[Class( NameType = typeof( LongPaperWitnesses ), Table = "`LongPaperWitnesses`", Polymorphism = PolymorphismType.Explicit
, Mutable = false, Lazy = false, DynamicUpdate = false, DynamicInsert = false, OptimisticLock = OptimisticLockMode.None )]
public partial class LongPaperWitnesses : ObjectState {
#region Fields
private string _id;
private IProduct _product =new ProductHeader();
private string _WitnessName1;
#endregion
#region Ctors
public LongPaperWitnesses() {
}
#endregion
#region Properties
[Id( 0, Name = "Id", Length = 100, Access = "property", TypeType = typeof( string ) )]
[Column( 1, Name = "`PrdKey`", Length = 100, Unique = true, NotNull = true )]
[Generator( 2, Class = "native" )]
public virtual string Id {
get {
return _id;
}
set {
_id = value;
}
}
[ManyToOne( 1, Name = "Product", ClassType = typeof( LongCrash ), Column = "`PrdKey`", Unique = true, NotNull = true
, Update = false, Insert = false, Cascade = CascadeStyle.None
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto )]
public virtual IProduct Product {
get {
return this._product;
}
set {
_product = value;
}
}
#region Other Properties
[Property( Name = "WitnessName1", Column = "`WitnessName1`", Access = "property"
, TypeType = typeof( string ), Insert = false, Update = false )]
public virtual string WitnessName1 {
get {
return this._WitnessName1;
}
set {
if ( ( this._WitnessName1 != value ) ) {
this.OnChanging();
this._WitnessName1 = value;
this.OnChanged();
}
}
}
#endregion
#endregion
#region Methods
public override string ToString() {
return Id != null ? Id.ToString() : "<null>";
}
#endregion
}
[Class( NameType = typeof( ShortContributingCauses ), ProxyType = typeof( IContributingCauses ), Table = "`Short_ContributingCauses`"
, Polymorphism = PolymorphismType.Explicit, Mutable = false, Lazy = false
, DynamicUpdate = false, DynamicInsert = false, OptimisticLock = OptimisticLockMode.None )]
public partial class ShortContributingCauses : ContributingCauses, IContributingCauses {
#region Ctors
public ShortContributingCauses() {
}
#endregion
#region Properties
[Id( 0, Name = "Id", Length = 100, Access = "property", TypeType = typeof( string ) )]
[Column( 1, Name = "`PrdKey`", Length = 100, Unique = true, NotNull = true )]
[Generator( 2, Class = "native" )]
public override string Id {
get {
return base.Id;
}
set {
base.Id = value;
}
}
[ManyToOne( 1, Name = "Product", ClassType = typeof( ShortCrash ), Column = "`PrdKey`", Unique = true, NotNull = true
, Update = false, Insert = false, Cascade = CascadeStyle.None
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto )]
public override IProduct Product {
get {
return base.Product;
}
set {
base.Product = value;
}
}
#region Other Properties
[Property( Name = "CauseEnvironment1", /*Column*/Formula = "`CauseEnvironment1`", Access = "property"
, TypeType = typeof( string ), Insert = false, Update = false )]
public override string CauseEnvironment1 {
get {
return base.CauseEnvironment1;
}
set {
if ( ( base.CauseEnvironment1 != value ) ) {
base.CauseEnvironment1 = value;
}
}
}
#endregion
#endregion
#region Methods
public override string ToString() {
return base.Id != null ? base.Id.ToString() : "";
}
#endregion
}
[JoinedSubclass( NameType = typeof( ShortTimeLocation ), ExtendsType = typeof( LOCATION ), ProxyType = typeof( ILocation )
, Table = "`Short_TimeLocation`", Lazy = false, DynamicUpdate = false, DynamicInsert = false )]
public partial class ShortTimeLocation : LOCATION, ILocation {
#region Fields
private string _AgencyReportNumber;
private IProduct _product =new ProductHeader();
#endregion
#region Ctors
public ShortTimeLocation() {
}
#endregion
#region Properties
[Key( 0, Column = "`LocationColKey`" )]
[Generator( 1, Class = "native" )]
public override string Id {
get {
return base.Id;
}
set {
if ( ( base.Id != value ) ) {
base.Id = value;
}
}
}
[ManyToOne( 1, Name = "Product", ClassType = typeof( ShortCrash ), Column = "`PrdKey`", Unique = true, NotNull = true
, Update = false, Insert = false, Cascade = CascadeStyle.None
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto )]
public virtual IProduct Product {
get {
return this._product;
}
set {
_product = value;
}
}
#region Other Properties
[Property( Name = "AgencyReportNumber", /*Column*/Formula = "`AgencyReportNumber`", Access = "property"
, TypeType = typeof( string ), Insert = false, Update = false )]
public virtual string AgencyReportNumber {
get {
return this._AgencyReportNumber;
}
set {
if ( ( this._AgencyReportNumber != value ) ) {
this._AgencyReportNumber = value;
}
}
}
#endregion
#endregion
}
[Class( NameType = typeof( ShortVehiclePedestrian ), ProxyType = typeof( IVehiclePedestrian ), Table = "`Short_VehiclePedestrian`"
, Polymorphism = PolymorphismType.Explicit, Mutable = false, Lazy = false, DynamicUpdate = false, DynamicInsert = false )]
public partial class ShortVehiclePedestrian : VehiclePedestrian, IVehiclePedestrian {
#region Ctors
public ShortVehiclePedestrian() {
}
#endregion
#region Properties
[Id( 0, Name = "Id", Length = 100, Access = "property", TypeType = typeof( string ) )]
[Column( 1, Name = "`PrdKey`", Length = 100, Unique = true, NotNull = true )]
[Generator( 2, Class = "native" )]
public override string Id {
get {
return base.Id;
}
set {
base.Id = value;
}
}
[ManyToOne( 1, Name = "Product", ClassType = typeof( ShortCrash ), Column = "`PrdKey`", Unique = true, NotNull = true
, Update = false, Insert = false, Cascade = CascadeStyle.None
, Fetch = FetchMode.Join, OuterJoin = OuterJoinStrategy.Auto )]
public override IProduct Product {
get {
return base.Product;
}
set {
base.Product = value;
}
}
#region Other Properties
[Property( Name = "EstDamage1", Formula = "`EstDamage1`", Access = "property"
, TypeType = typeof( string ), Insert = false, Update = false )]
public override string EstDamage1 {
get {
return base.EstDamage1;
}
set {
if ( ( base.EstDamage1 != value ) ) {
base.EstDamage1 = value;
}
}
}
#endregion
#endregion
#region Methods
public override string ToString() {
return base.Id != null ? base.Id.ToString() : "";
}
#endregion
}
Mapping documents:Code:
<?xml version="1.0" encoding="utf-8"?>
<!--Generated from NHibernate.Mapping.Attributes on 2006-09-21 10:26:30Z.-->
<hibernate-mapping default-cascade="none" default-access="property" assembly="Tracs.Florida.Data.DataModels.TracsDb.Generic, Version=1.0.2455.16933, Culture=neutral, PublicKeyToken=null" xmlns="urn:nhibernate-mapping-2.0">
<class name="Tracs.Florida.Data.DataModels.TracsDb.Generic.ProductHeader, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.IProduct, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" table="`Prd_Header`" mutable="false" polymorphism="explicit">
<id name="Id" access="property" type="String" length="100">
<column name="`PrdKey`" length="100" not-null="true" unique="true" />
<generator class="native" />
</id>
<discriminator column="`PrdName`" />
<property name="CaseNumber" access="property" type="String" column="`CaseNumber`" not-null="false" update="false" insert="false" />
<property name="ProductName" access="property" type="String" column="`PrdName`" length="100" update="false" insert="false" />
</class>
<class name="Tracs.Florida.Data.DataModels.TracsDb.Generic.LOCATION, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.ILocation, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" table="`LOCATION`" discriminator-value="LOCATION" mutable="false" polymorphism="explicit">
<id name="Id" access="property" type="String" length="100">
<column name="`COLLKEY`" length="100" unique="true" />
<generator class="native" />
</id>
<property name="Latitude" access="property" type="String" column="`Latitude`" not-null="false" update="false" insert="false" />
<property name="Longitude" access="property" type="String" column="`Longitude`" not-null="false" update="false" insert="false" />
<many-to-one name="Product" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.ProductHeader, Tracs.Florida.Data.DataModels.TracsDb.Generic" column="`PrdKey`" unique="true" cascade="none" outer-join="auto" fetch="join" update="false" insert="false" />
</class>
<class name="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperContributingCauses, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.IContributingCauses, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" table="`LongPaperContributingCauses`" mutable="false" polymorphism="explicit" optimistic-lock="none">
<id name="Id" access="property" type="String" length="100">
<column name="`PrdKey`" length="100" not-null="true" unique="true" />
<generator class="native" />
</id>
<property name="CauseEnvironment1" access="property" type="String" update="false" insert="false" formula="`CauseEnvironment1`" />
<many-to-one name="Product" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongCrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" column="`PrdKey`" not-null="true" unique="true" cascade="none" outer-join="auto" fetch="join" update="false" insert="false" />
</class>
<class name="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperPassenger, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" table="`LongPaperPassengers`" mutable="false" polymorphism="explicit" optimistic-lock="none">
<id name="Id" access="property" type="String" length="100">
<column name="`PrdKey`" length="100" unique="true" />
<generator class="native" />
</id>
<property name="PassengerName1" access="property" type="String" column="`PassengerName1`" update="false" insert="false" />
<many-to-one name="Product" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongCrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" column="`PrdKey`" not-null="true" unique="true" cascade="none" outer-join="auto" fetch="join" update="false" insert="false" />
</class>
<class name="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperVehiclePedestrian, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.IVehiclePedestrian, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" table="`LongPaperVehiclePedestrian`" mutable="false" polymorphism="explicit" optimistic-lock="none">
<id name="Id" access="property" type="String" length="100">
<column name="`PrdKey`" length="100" not-null="true" unique="true" />
<generator class="native" />
</id>
<property name="EstDamage1" access="property" type="String" update="false" insert="false" formula="`EstDamage1`" />
<many-to-one name="Product" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongCrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" column="`PrdKey`" not-null="true" unique="true" cascade="none" outer-join="auto" fetch="join" update="false" insert="false" />
</class>
<class name="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperWitnesses, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" table="`LongPaperWitnesses`" mutable="false" polymorphism="explicit" optimistic-lock="none">
<id name="Id" access="property" type="String" length="100">
<column name="`PrdKey`" length="100" not-null="true" unique="true" />
<generator class="native" />
</id>
<property name="WitnessName1" access="property" type="String" column="`WitnessName1`" update="false" insert="false" />
<many-to-one name="Product" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongCrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" column="`PrdKey`" not-null="true" unique="true" cascade="none" outer-join="auto" fetch="join" update="false" insert="false" />
</class>
<class name="Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortContributingCauses, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.IContributingCauses, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" table="`Short_ContributingCauses`" mutable="false" polymorphism="explicit" optimistic-lock="none">
<id name="Id" access="property" type="String" length="100">
<column name="`PrdKey`" length="100" not-null="true" unique="true" />
<generator class="native" />
</id>
<property name="CauseEnvironment1" access="property" type="String" update="false" insert="false" formula="`CauseEnvironment1`" />
<many-to-one name="Product" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortCrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" column="`PrdKey`" not-null="true" unique="true" cascade="none" outer-join="auto" fetch="join" update="false" insert="false" />
</class>
<class name="Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortVehiclePedestrian, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.IVehiclePedestrian, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" table="`Short_VehiclePedestrian`" mutable="false" polymorphism="explicit">
<id name="Id" access="property" type="String" length="100">
<column name="`PrdKey`" length="100" not-null="true" unique="true" />
<generator class="native" />
</id>
<property name="EstDamage1" access="property" type="String" update="false" insert="false" formula="`EstDamage1`" />
<many-to-one name="Product" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortCrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" column="`PrdKey`" not-null="true" unique="true" cascade="none" outer-join="auto" fetch="join" update="false" insert="false" />
</class>
<subclass name="Tracs.Florida.Data.DataModels.TracsDb.Generic.Crash, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.ICrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" extends="Tracs.Florida.Data.DataModels.TracsDb.Generic.ProductHeader, Tracs.Florida.Data.DataModels.TracsDb.Generic" discriminator-value="base" />
<subclass name="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongCrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.ICrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" extends="Tracs.Florida.Data.DataModels.TracsDb.Generic.Crash, Tracs.Florida.Data.DataModels.TracsDb.Generic" discriminator-value="CRASH-LONG">
<one-to-one name="Location" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperTimeLocation, Tracs.Florida.Data.DataModels.TracsDb.Generic" cascade="none" outer-join="auto" fetch="join" property-ref="Product" />
<one-to-one name="ContributingCauses" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperContributingCauses, Tracs.Florida.Data.DataModels.TracsDb.Generic" cascade="none" outer-join="auto" fetch="join" property-ref="Product" />
<one-to-one name="VehiclePedestrians" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperVehiclePedestrian, Tracs.Florida.Data.DataModels.TracsDb.Generic" cascade="none" outer-join="auto" fetch="join" property-ref="Product" />
<one-to-one name="Passengers" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperPassenger, Tracs.Florida.Data.DataModels.TracsDb.Generic" cascade="none" outer-join="auto" fetch="join" property-ref="Product" />
<one-to-one name="Witnesses" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperWitnesses, Tracs.Florida.Data.DataModels.TracsDb.Generic" cascade="none" outer-join="auto" fetch="join" property-ref="Product" />
</subclass>
<subclass name="Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortCrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.ICrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" extends="Tracs.Florida.Data.DataModels.TracsDb.Generic.Crash, Tracs.Florida.Data.DataModels.TracsDb.Generic" discriminator-value="ShortCrash">
<one-to-one name="Location" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortTimeLocation, Tracs.Florida.Data.DataModels.TracsDb.Generic" cascade="none" outer-join="auto" fetch="join" property-ref="Product" />
<one-to-one name="ContributingCauses" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortContributingCauses, Tracs.Florida.Data.DataModels.TracsDb.Generic" cascade="none" outer-join="auto" fetch="join" property-ref="Product" />
<one-to-one name="VehiclePedestrians" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortVehiclePedestrian, Tracs.Florida.Data.DataModels.TracsDb.Generic" cascade="none" outer-join="auto" fetch="join" property-ref="Product" />
</subclass>
<joined-subclass name="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperTimeLocation, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.ILocation, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" extends="Tracs.Florida.Data.DataModels.TracsDb.Generic.LOCATION, Tracs.Florida.Data.DataModels.TracsDb.Generic" table="`LongPaperTimeLocation`">
<key column="`LocationColKey`" />
<property name="AgencyReportNumber" access="property" type="String" not-null="false" update="false" insert="false" formula="`AgencyReportNumbert`" />
<many-to-one name="Product" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.LongCrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" column="`PrdKey`" cascade="none" outer-join="true" fetch="join" update="false" insert="false" />
</joined-subclass>
<joined-subclass name="Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortTimeLocation, Tracs.Florida.Data.DataModels.TracsDb.Generic" proxy="Tracs.Florida.Data.DataModels.TracsDb.Generic.ILocation, Tracs.Florida.Data.DataModels.TracsDb.Generic" lazy="false" dynamic-update="false" dynamic-insert="false" extends="Tracs.Florida.Data.DataModels.TracsDb.Generic.LOCATION, Tracs.Florida.Data.DataModels.TracsDb.Generic" table="`Short_TimeLocation`">
<key column="`LocationColKey`" />
<property name="AgencyReportNumber" access="property" type="String" update="false" insert="false" formula="`AgencyReportNumber`" />
<many-to-one name="Product" access="property" class="Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortCrash, Tracs.Florida.Data.DataModels.TracsDb.Generic" column="`PrdKey`" cascade="none" outer-join="auto" fetch="join" update="false" insert="false" />
</joined-subclass>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
try {
factory = cfg.BuildSessionFactory();
session = factory.OpenSession();
session.FlushMode = FlushMode.Never;
#region New up a data object and set some properties
ICrash crash = new Crash();
crash.Location.Latitude = "30.2";
crash.Location.Longitude = "-81.7";
crash.CaseNumber = "35907";
#endregion
#region Set the QBE with an ICriteria object
NHibernate.ICriteria criteria;
NHibernate.Expression.Example example = NHibernate.Expression.Example.Create( crash );
example.ExcludeNulls()
.IgnoreCase()
.EnableLike( NHibernate.Expression.MatchMode.Anywhere );
criteria = session.CreateCriteria( crash.GetType() )
.Add( example );
if ( crash.ContributingCauses != null && crash.ContributingCauses.Dirty ) {
NHibernate.Expression.Example subExample = NHibernate.Expression.Example.Create( crash.ContributingCauses );
subExample.ExcludeNulls()
.IgnoreCase()
.EnableLike( NHibernate.Expression.MatchMode.Anywhere );
NHibernate.ICriteria subCrit = criteria.CreateCriteria( "ContributingCauses" )
.Add( subExample );
}
if ( crash.Location != null && crash.Location.Dirty ) {
NHibernate.Expression.Example subExample = NHibernate.Expression.Example.Create( crash.Location );
subExample.ExcludeNulls()
.IgnoreCase()
.EnableLike( NHibernate.Expression.MatchMode.Anywhere );
NHibernate.ICriteria subCrit = criteria.CreateCriteria( "Location" )
.Add( subExample );
}
if ( crash.VehiclePedestrians != null && crash.VehiclePedestrians.Dirty ) {
NHibernate.Expression.Example subExample = NHibernate.Expression.Example.Create( crash.VehiclePedestrians );
subExample.ExcludeNulls()
.IgnoreCase()
.EnableLike( NHibernate.Expression.MatchMode.Anywhere );
NHibernate.ICriteria subCrit = criteria.CreateCriteria( "VehiclePedestrians" )
.Add( subExample );
}
#endregion
IList<LongCrash> results = null;
#region Begin transaction and attempt to get an IList from the ICriteria
try {
if ( !session.IsConnected ) {
session.Reconnect();
}
session.BeginTransaction();
criteria.SetCacheable( true );
results = criteria.List<LongCrash>();
session.Transaction.Commit();
}
catch {
if ( session.Transaction != null ) {
session.Transaction.Rollback();
}
results = null;
throw;
}
finally {
}
#endregion
}
finally {
if ( factory != null )
factory.Close();
if ( session != null ) {
if ( session.IsConnected )
session.Disconnect();
if ( session.IsOpen )
session.Close();
session.Dispose();
}
}
Full stack trace of any exception that occurs:
Test method TracsFloridaTestProject.TracsFloridaDataDataModelsTracsDbGenericTest.QBETest threw exception: System.InvalidCastException: Unable to cast object of type 'Tracs.Florida.Data.DataModels.TracsDb.Generic.LOCATION' to type 'Tracs.Florida.Data.DataModels.TracsDb.Generic.ShortTimeLocation'..
at (Object , GetterCallback )
at NHibernate.Bytecode.Lightweight.GetPropertyValuesInvoker.Invoke(Object obj, GetterCallback callback)
at NHibernate.Bytecode.Lightweight.AccessOptimizer.GetPropertyValues(Object target) in D:\Downloads\dotNet\NHibernate\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Bytecode\Lightweight\AccessOptimizer.cs:line 28
at NHibernate.Persister.Entity.AbstractEntityPersister.GetPropertyValues(Object obj) in D:\Downloads\dotNet\NHibernate\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 229
at NHibernate.Expression.Example.ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery) in D:\Downloads\dotNet\NHibernate\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Expression\Example.cs:line 264
at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetWhereCondition() in D:\Downloads\dotNet\NHibernate\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Loader\Criteria\CriteriaQueryTranslator.cs:line 362
at NHibernate.Loader.Criteria.CriteriaJoinWalker..ctor(IOuterJoinLoadable persister, CriteriaQueryTranslator translator, ISessionFactoryImplementor factory, CriteriaImpl criteria, Type rootEntityName, IDictionary enabledFilters) in D:\Downloads\dotNet\NHibernate\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Loader\Criteria\CriteriaJoinWalker.cs:line 71
at NHibernate.Loader.Criteria.CriteriaLoader..ctor(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria, Type rootEntityName, IDictionary enabledFilters) in D:\Downloads\dotNet\NHibernate\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Loader\Criteria\CriteriaLoader.cs:line 45
at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results) in D:\Downloads\dotNet\NHibernate\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Impl\SessionImpl.cs:line 4881
at NHibernate.Impl.SessionImpl.Find[T](CriteriaImpl criteria) in D:\Downloads\dotNet\NHibernate\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Impl\SessionImpl.cs:line 4856
at NHibernate.Impl.CriteriaImpl.List[T]() in D:\Downloads\dotNet\NHibernate\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Impl\CriteriaImpl.cs:line 285
at TracsFloridaTestProject.TracsFloridaDataDataModelsTracsDbGenericTest.QBETest()
Name and version of the database you are using:
SQL Server 2005 (2000 format)
The generated SQL (show_sql=true):
10:26:47.859 [AdpaterExeMgrThread1] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader - Static select for entity Tracs.Florida.Data.DataModels.TracsDb.Generic.LongPaperWitnesses: SELECT longpaperw0_.[PrdKey] as PrdKey1_9_, longpaperw0_.[PrdKey] as PrdKey1_5_9_, longpaperw0_.[WitnessName1] as WitnessN2_5_9_, longcrash1_.[PrdKey] as PrdKey1_0_, longcrash1_.[CaseNumber] as CaseNumber3_0_0_, longcrash1_.[PrdName] as PrdName2_0_0_, longpaperp2_.[PrdKey] as PrdKey1_1_, longpaperp2_.[PrdKey] as PrdKey1_3_1_, longpaperp2_.[PassengerName1] as Passenge2_3_1_, longpapert3_.[LocationColKey] as COLLKEY1_2_, longpapert3_.[PrdKey] as PrdKey2_8_2_, longpapert3_1_.[PrdKey] as PrdKey4_1_2_, longpapert3_1_.[Longitude] as Longitude3_1_2_, longpapert3_1_.[Latitude] as Latitude2_1_2_, longpapert3_.[AgencyReportNumbert] as formula4_2_, producthea4_.[PrdKey] as PrdKey1_3_, producthea4_.[CaseNumber] as CaseNumber3_0_3_, producthea4_.[PrdName] as PrdName2_0_3_, producthea4_.[PrdName] as PrdName2_3_, longpaperc5_.[PrdKey] as PrdKey1_4_, longpaperc5_.[PrdKey] as PrdKey1_2_4_, longpaperc5_.[CauseEnvironment1] as formula0_4_, longpaperv6_.[PrdKey] as PrdKey1_5_, longpaperv6_.[PrdKey] as PrdKey1_4_5_, longpaperv6_.[EstDamage1] as formula1_5_, shorttimel7_.[LocationColKey] as COLLKEY1_6_, shorttimel7_.[PrdKey] as PrdKey2_9_6_, shorttimel7_1_.[PrdKey] as PrdKey4_1_6_, shorttimel7_1_.[Longitude] as Longitude3_1_6_, shorttimel7_1_.[Latitude] as Latitude2_1_6_, shorttimel7_.[AgencyReportNumber] as formula5_6_, shortcontr8_.[PrdKey] as PrdKey1_7_, shortcontr8_.[PrdKey] as PrdKey1_6_7_, shortcontr8_.[CauseEnvironment1] as formula2_7_, shortvehic9_.[PrdKey] as PrdKey1_8_, shortvehic9_.[PrdKey] as PrdKey1_7_8_, shortvehic9_.[EstDamage1] as formula3_8_ FROM [LongPaperWitnesses] longpaperw0_ inner join [Prd_Header] longcrash1_ on longpaperw0_.[PrdKey]=longcrash1_.[PrdKey] left outer join [LongPaperPassengers] longpaperp2_ on longcrash1_.[PrdKey]=longpaperp2_.[PrdKey] left outer join [LongPaperTimeLocation] longpapert3_ on longcrash1_.[PrdKey]=longpapert3_.[PrdKey] left outer join [LOCATION] longpapert3_1_ on longpapert3_.[LocationColKey]=longpapert3_1_.[COLLKEY] left outer join [Prd_Header] producthea4_ on longpapert3_1_.[PrdKey]=producthea4_.[PrdKey] left outer join [LongPaperContributingCauses] longpaperc5_ on producthea4_.[PrdKey]=longpaperc5_.[PrdKey] left outer join [LongPaperVehiclePedestrian] longpaperv6_ on producthea4_.[PrdKey]=longpaperv6_.[PrdKey] left outer join [Short_TimeLocation] shorttimel7_ on producthea4_.[PrdKey]=shorttimel7_.[PrdKey] left outer join [LOCATION] shorttimel7_1_ on shorttimel7_.[LocationColKey]=shorttimel7_1_.[COLLKEY] left outer join [Short_ContributingCauses] shortcontr8_ on producthea4_.[PrdKey]=shortcontr8_.[PrdKey] left outer join [Short_VehiclePedestrian] shortvehic9_ on producthea4_.[PrdKey]=shortvehic9_.[PrdKey] WHERE longpaperw0_.[PrdKey]=:[PrdKey]
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this: h