I get an exception when trying to get a collection lazily - invalid SQL. The mapping file is below the log4net text as well...
Quote:
2250 [1696] DEBUG NHibernate.Impl.SessionImpl (null) - initializing collection [TestBOM.Employee._Offices#32769]
2250 [1696] DEBUG NHibernate.Impl.SessionImpl (null) - checking second-level cache
2250 [1696] DEBUG NHibernate.Impl.SessionImpl (null) - collection not cached
2265 [1696] DEBUG NHibernate.Impl.BatcherImpl (null) - Opened new IDbCommand, open IDbCommands :1
2265 [1696] DEBUG NHibernate.Impl.BatcherImpl (null) - Building an IDbCommand object for the SqlString: SELECT _offices0_.employee_id as employee1___, _offices0_.office_id as office_id__, office1_.Id as Id
0_, office1_.BuildingNumber as Building2_0_ FROM employee_office _offices0_ inner join offices office1_ on _offices0_.office_id=office1_.Id WHERE _offices0_.employee_id=:employee_id
2265 [1696] DEBUG NHibernate.Type.NullableType (null) - binding '32769' to parameter: 0
2281 [1696] INFO NHibernate.Loader.Loader (null) - SELECT _offices0_.employee_id as employee1___, _offices0_.office_id as office_id__, office1_.Id as Id0_, office1_.BuildingNumber as Building2_0_ FROM empl
oyee_office _offices0_ inner join offices office1_ on _offices0_.office_id=office1_.Id WHERE _offices0_.employee_id=@p0
2281 [1696] DEBUG NHibernate.SQL (null) - SELECT _offices0_.employee_id as employee1___, _offices0_.office_id as office_id__, office1_.Id as Id0_, office1_.BuildingNumber as Building2_0_ FROM employee_offi
ce _offices0_ inner join offices office1_ on _offices0_.office_id=office1_.Id WHERE _offices0_.employee_id=@p0
2390 [1696] DEBUG NHibernate.Util.ADOExceptionReporter (null) - SQL Exception
FirebirdSql.Data.Firebird.FbException: Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 18
.
at FirebirdSql.Data.Firebird.FbCommand.ExecuteReader(CommandBehavior behavior)
at FirebirdSql.Data.Firebird.FbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
2421 [1696] WARN NHibernate.Util.ADOExceptionReporter (null) - FirebirdSql.Data.Firebird.FbException: Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 18
.
at FirebirdSql.Data.Firebird.FbCommand.ExecuteReader(CommandBehavior behavior)
at FirebirdSql.Data.Firebird.FbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
2437 [1696] ERROR NHibernate.Util.ADOExceptionReporter (null) - Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 18
.
2453 [1696] DEBUG NHibernate.Impl.BatcherImpl (null) - Closed IDbCommand, open IDbCommands :0
2453 [1696] ERROR NHibernate.ADOException (null) - could not initialize collection: [TestBOM.Employee._Offices#32769]
FirebirdSql.Data.Firebird.FbException: Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 18
.
at FirebirdSql.Data.Firebird.FbCommand.ExecuteReader(CommandBehavior behavior)
at FirebirdSql.Data.Firebird.FbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys
, Boolean returnProxies)
at NHibernate.Loader.CollectionLoader.Initialize(Object id, ISessionImplementor session)
at NHibernate.Collection.AbstractCollectionPersister.Initialize(Object key, ISessionImplementor session)
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="TestBOM.Employer,TestBOM" table="employers">
<jcs-cache usage="read-write"/>
<id name="Id">
<generator class="NHibernate.Id.TableHiLoGenerator">
<param name="table">LASTEMPLOYERS</param>
<param name="column">LASTID</param>
</generator>
</id>
<property name="Name"/>
</class>
<class name="TestBOM.Employment,TestBOM" table="employment_periods">
<jcs-cache usage="read-write"/>
<id name="Id">
<generator class="NHibernate.Id.TableHiLoGenerator">
<param name="table">LASTEMPLOYMENT_PERIODS</param>
<param name="column">LASTID</param>
</generator>
</id>
<property name="StartDate" column="start_date"/>
<property name="EndDate" column="end_date"/>
<component name="HourlyRate" class="TestBOM.MonetoryAmount,TestBOM">
<property name="Amount">
<column name="hourly_rate" sql-type="NUMERIC(12, 2)"/>
</property>
<property name="Currency" length="12"/>
</component>
<many-to-one name="LEmployer" column="employer_id" not-null="true"/>
<many-to-one name="LEmployee" column="employee_id" not-null="true"/>
</class>
<class name="TestBOM.Employee,TestBOM" table="employees">
<!--jcs-cache usage="read-write"/-->
<id name="Id">
<generator class="NHibernate.Id.TableHiLoGenerator">
<param name="table">lastemployees</param>
<param name="column">LASTID</param>
</generator>
</id>
<property name="TaxFileNumber"/>
<component name="LName" class="TestBOM.Name,TestBOM">
<property name="FirstName"/>
<property name="Initial"/>
<property name="LastName"/>
</component>
<bag name="_Offices" table="employee_office" access="field" lazy="true">
<key>
<column name="employee_id" not-null="true"/>
</key>
<many-to-many class="TestBOM.Office,TestBOM">
<column name="office_id" not-null="true"/>
</many-to-many>
</bag>
</class>
<class name="TestBOM.Office,TestBOM" table="offices">
<jcs-cache usage="read-write"/>
<id name="Id">
<generator class="NHibernate.Id.TableHiLoGenerator">
<param name="table">lastoffices</param>
<param name="column">LASTID</param>
</generator>
</id>
<property name="BuildingNumber"/>
<bag name="_Employees" table="employee_office" access="field" lazy="true">
<key column="office_id"/>
<many-to-many class="TestBOM.Employee,TestBOM" column="employee_id"/>
</bag>
</class>
<query name="TestBOM.Office.OfficeByBuildingNumber">
<![CDATA[
from TestBOM.Office as Office
where Office.BuildingNumber = ?]]>
</query>
</hibernate-mapping>