boujnah5207 / sharp-architecture

Automatically exported from code.google.com/p/sharp-architecture
Other
0 stars 0 forks source link

nHibernate pluralizes a table in the from clause #119

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Upgraded to the latest release. System ran fine before upgrade.

When I do a "get all" nHibernate throws an exception saying it cannot 
locate the entity Projects.

I have a Project that is inner joined with a Property but no Projects.

Reverted back to the original release and all is well.

Including the Fluent Map for Project:

using FluentNHibernate.Mapping;
using WIRED.Core.Entities.Persisted;
using WIRED.Data.NHibernateMaps.ValueObjects;

namespace WIRED.Data.NHibernateMaps.Entities
{
    public sealed class ProjectMap : ClassMap<Project>
    {
        public ProjectMap()
        {
            Id(x => x.Id);
            Map(x => x.ProjectId).Unique().Not.Nullable().UniqueKey
("ProjectProperty");
            Map(x => x.Name).Not.Nullable();
            Map(x => x.Description);
            Map(x => x.Source).Not.Nullable();
            Map(x => x.Administrator).Not.Nullable();
            Map(x => x.ProjectCategory).Not.Nullable();
            Component(c => c.Audit, AuditMap.Map(""));
            References(x => x.Property, "FK_Property").Not.Nullable
().FetchType.Join().UniqueKey("ProjectProperty");
            HasMany(x => x.Templates).KeyColumnNames.Add
("FK_Project").Cascade.All().Inverse().LazyLoad();
            HasMany(x => x.Comments).KeyColumnNames.Add
("FK_Project").Cascade.All().Inverse().LazyLoad();
        }
    }
}

Exception:

System.Data.SqlClient.SqlException: Invalid object name 'Projects'.

SQL:

2009-08-18 06:58:41,687 [9] NHibernate.AdoNet.AbstractBatcher.ExecuteReader
(:0) - Could not execute query: SELECT this_.Id as Id4_1_, this_.Creator 
as Creator4_1_, this_.CreateDate as CreateDate4_1_, this_.ModifiedBy as 
ModifiedBy4_1_, this_.UpdateDate as UpdateDate4_1_, this_.ProjectId as 
ProjectId4_1_, this_.Name as Name4_1_, this_.Description as 
Descript8_4_1_, this_.Source as Source4_1_, this_.Administrator as 
Adminis10_4_1_, this_.ProjectCategory as Project11_4_1_, this_.PropertyFk 
as PropertyFk4_1_, property2_.Id as Id7_0_, property2_.AD_AddressLine as 
AD2_7_0_, property2_.AD_AddressLine1 as AD3_7_0_, property2_.AD_City as 
AD4_7_0_, property2_.AD_County as AD5_7_0_, property2_.AD_State as 
AD6_7_0_, property2_.AD_Zip as AD7_7_0_, property2_.GEO_Latitude as 
GEO8_7_0_, property2_.GEO_Longitude as GEO9_7_0_, property2_.LA_Area as 
LA10_7_0_, property2_.LA_Dimension as LA11_7_0_, property2_.MD_Branch as 
MD12_7_0_, property2_.MD_Group as MD13_7_0_, property2_.MD_Area as 
MD14_7_0_, property2_.MD_ReportCity as MD15_7_0_, property2_.MD_Market as 
MD16_7_0_, property2_.FS_LoanStatus as FS17_7_0_, 
property2_.FS_LoanMaturityDate as FS18_7_0_, property2_.FS_TaxFolioNumber 
as FS19_7_0_, property2_.FS_LoanShare as FS20_7_0_, 
property2_.FS_LandCostAmount as FS21_7_0_, property2_.FS_LandCostCurrency 
as FS22_7_0_, property2_.FS_StructureCostAmount as FS23_7_0_, 
property2_.FS_StructureCostCurrency as FS24_7_0_, 
property2_.FS_InitialLoanValueAmount as FS25_7_0_, 
property2_.FS_InitialLoanValueCurrency as FS26_7_0_, 
property2_.FS_LoanBalanceAmount as FS27_7_0_, 
property2_.FS_LoanBalanceCurrency as FS28_7_0_, 
property2_.FS_LegalBalanceAmount as FS29_7_0_, 
property2_.FS_LegalBalanceCurrency as FS30_7_0_, 
property2_.FS_LandAppraisalType as FS31_7_0_, 
property2_.FS_LandAppraisalDate as FS32_7_0_, 
property2_.FS_LandAppraisedValueAmount as FS33_7_0_, 
property2_.FS_LandAppraisedValueCurrency as FS34_7_0_, 
property2_.FS_StructureAppraisalType as FS35_7_0_, 
property2_.FS_StructureAppraisalDate as FS36_7_0_, 
property2_.FS_StructureAppraisedValueAmount as FS37_7_0_, 
property2_.FS_StructureAppraisedValueCurrency as FS38_7_0_, 
property2_.SA_Area as SA39_7_0_, property2_.SA_Dimension as SA40_7_0_, 
property2_.RecommendationComment as Recomme41_7_0_, 
property2_.RecommendationChoice as Recomme42_7_0_, 
property2_.Audit_Creator as Audit43_7_0_, property2_.Audit_CreateDate as 
Audit44_7_0_, property2_.Audit_ModifiedBy as Audit45_7_0_, 
property2_.Audit_UpdateDate as Audit46_7_0_, property2_.PropertyId as 
PropertyId7_0_, property2_.Name as Name7_0_, property2_.Description as 
Descrip49_7_0_, property2_.LeaseOwned as LeaseOwned7_0_, 
property2_.LeaseType as LeaseType7_0_, property2_.PropertyType as 
Propert52_7_0_, property2_.LegalStatus as LegalSt53_7_0_, 
property2_.CompletionStatus as Complet54_7_0_ FROM Projects this_ inner 
join Properties property2_ on this_.PropertyFk=property2_.Id

Original issue reported on code.google.com by jurri...@gmail.com on 18 Aug 2009 at 12:09

GoogleCodeExporter commented 9 years ago
Has anyone lookied into this problem?

I upgraded to the latest version to try and solve a deployment issue with IIS7 
and 
this problem surfaced again.

Is this a problem with my code, Sharp or NHibernate?

Some assitance would be helpfull.

Original comment by jurri...@gmail.com on 11 Sep 2009 at 7:45

GoogleCodeExporter commented 9 years ago
Are you using any FNH conventions that would automatically pluralize the table 
name for 
all entities?

Original comment by wmccaffe...@gmail.com on 30 Sep 2009 at 9:28

GoogleCodeExporter commented 9 years ago
If I was using a FNH that pluralizes name wouldn't I fail no matter which 
version of 
Sharp I was using?

I don't have anything to my knowledge that does that.

Original comment by jurri...@gmail.com on 1 Oct 2009 at 10:12

GoogleCodeExporter commented 9 years ago
I believe there was a change in Fluent NH with respect to the order in which 
conventions were applied.  If this is still an issue for you and you would like 
further 
clarification of the cause, please bring up this subject on the Fluent NH forum 
at 
http://groups.google.com/group/fluent-nhibernate

Original comment by wmccaffe...@gmail.com on 29 Oct 2009 at 9:12