fluent-nhibernate

How to avoid DateTime truncation with composite key in NHibernate?

I have the following (using Fluent NHibernate): public class BuildAuditMap : ClassMap<BuildAudit> { public BuildAuditMap() { Table("BUILD_AUDIT"); CompositeId() .KeyProperty(x => x.AuditDate, c => c.ColumnName("AUDIT_DATE")) .KeyProperty(x => x.PersonId, c => c.ColumnName("PERSON_ID")); ...

Problem Deleting with Parent/Child

Hi, I have an issue when deleting a child record from the session. Here are the entities i have defined: public class ReportedData { public virtual int ReportedDataID { get; set; } public virtual ReportedDataTypes Type { get; set; } public virtual string Reason { get; set; } public virtual IList<ArticleCommentReported>...

Why does this HQL delete fail, when an HQL select with same terms works?

Why does the following HQL query fail? string hql = @"delete MyLog log where log.UtcTimestamp < :threshold and log.Configuration.Application = :application"; session.CreateQuery(hql) .SetDateTime("threshold", threshold) .SetEnum("application", this.application) ...

Auto Increment in FLuent Nhibernate and PostgreSQL

Hai, I`m Newbie in Fluent Nhibernate.. I have postgreSql Database and what i want is generated id with auto increment.. i have no see feature auto increment in Postgres and i was understand that for use auto increment in postgreSql i must create sequence.. there is other way beside sequence? if create sequence is the only way, can You ...

using fluent-nhibernate, is there convention to make the foreign-key column in one-to-many relation not null ?

I'm using fluent-nhibernate conventions to map my entityies: public class HasManyConvention : IHasManyConvention { public void Apply(FluentNHibernate.Conventions.Instances.IOneToManyCollectionInstance instance) { instance.Key.Column(instance.EntityType.Name + "ID"); instance.Cascade.AllDelete...

Why is Fluent NHibernate ignoring my convention?

Here is a small VS 2010 solution with a single failing test that replicates the following issue. I have a convention UserTypeConvention<MyUserType> where MyUserType : IUserType where MyUserType handles an enum type MyEnum. I have configured Fluent NHibernate thusly sessionFactory = Fluently .Configure() ...

How do I get NHibernate to save an entity if I assign it an ID, but generate one otherwise?

According to the REST philosophy, a PUT request should update the resource at a URL if it exists, and create it if it doesn't exist. So in other words, if I use the following URL: PUT http://server/item/5 If an Item exists with an ID of 5, it will be updated. If an Item doesn't exist with an ID of 5, a new Item will be created with an...

NHibernate one-to-many delete

I am working on an ASP.NET MVC application using NHibernate as the ORM. I have two domain objects: public class Contact { public int ID { get; set } public string Name { get;set; } public IList<ContactNumber> ContactNumbers { get; set; } } public class ContactNumber { p...

Fluent NHibernate different Conventions for different base types

Hi All At this moment we are keeping all Entities and Mappings into same assembly. Our entities derived from a basic class Entity which is an EntityWithTypedId Also we are having a table name Convention telling to pluralize the table names. Now I want to create other two base types e.q. AggregateRootEntity and AggregateEntity, both d...

Need help for my NHibernate mappings

Hello all, I have the following (simplified) mappings: public class RosterMap : ClassMap<Roster> { public RosterMap() { References(tr => tr.Team) .Not.Nullable(); HasMany(r => r.Players) .Inverse() .Cascade.AllDeleteOrphan(); References(roster => roster.Match) ...

FluentNHibernate mapping to existing database

Hi, While working on a project, i came across to a scenario where i have to ignore table creation for a spesific class using fluentnhibernate. Scenario I have an existing table aspnet_Users and I have a class Person that has all the attributes of the table as property, ie: UserName, Password, LastLoginDate. Now I need to configure Fl...

Stored procedure in nHibernate?

Is it possible to CREATE (not query) a stored procedure with nhibernate? ...

change the constraint name in fluentNhibernate auto mapping alteration

i'm using oracle with FluentNHibernate automapping with alterations & NHibernate the problem is how to specify the constraint name by overriding the mapping model?? the generated sql like this: alter table FirstTable add constraint FK_VerLongIdentifierLongerThan30Characther foreign key (FirstTableID) references SecondTable...

NHibernate - Why doesn't NHibernate insert child entities in one-to-many?

Hello.. In my example I have Servers and those Servers belong to a ServerGroup. I am populating a ServerGroup with Servers and saving the ServerGroup. The ServerGroup table is populated but the Servers are not. public ServerGroupMap() { Id(x => x.Id); Map(x => x.Name); HasMany(x => x.ServersInGroup) ...

Why is Fluent NHibernate ignoring my unique constraint on a component?

In my map I have: Component( x => x.ExposureKey, m => { m.Map(x => x.AsOfDate).Not.Nullable(); m.Map(x => x.ExposureId).Length(30).Not.Nullable(); } ).Unique(); The relevant output from the HBM is <component name="ExposureKey" insert="true" update="true" optimistic-lock="true" class="Some.Namespace.CreditE...

self-reflexive n:m relation using composite keys in nhibernate

I have a legacy database with 3 tables like this: The Items table contains all the Items in a Plan. The Structure table defines the relation between the items. A parent item is defined by company, year, planId and parentItem of table structure mapping to company, year, planId and id of table item. A child item is defined by company, yea...

Could not load an entity in NHibernate then Timeout Exception when Table is existing

I need help on this. I got this error while inserting/updating a number of records could not load an entity: [Star.CNPL_BusinessObjects.Entities.CNPL.CNPL_AgencyProduct#48][SQL: SELECT cnpl_agenc0_.Id as Id48_0_, cnpl_agenc0_.AgencyID as AgencyID48_0_, cnpl_agenc0_.ProductID as ProductID48_0_, cnpl_agenc0_.CreatedDate as CreatedD4_48_...

nhibernate - sproutcore : How to only retrieve reference ID's and not load the reference/relation ?

Hi All, I use as a front-end sproutcore, and as back-end an nhibernate driven openrasta REST solution. In sproutcore, references are actualy ID's / guid's. So an Address entity in the Sproutcore model could be: // sproutcore code App.Address = App.Base.extend( street: SC.Record.attr(String, { defaultValue: "" }), houseNumber: SC.R...

Fluent NHibernate Cacheing for Linq queries

I have just discovered that I don't think my nhibernate setup seems to be cacheing properly. I'm running a SQL server profiler and neither the 1st or 2nd level cache appear to be working. For my queries I'm using: var queryable = NHibernateSession.CurrentFor(NHibernateSession.DefaultFactoryKey).Linq<Accommodation>(); queryable.QueryOpt...

Possible to Define Filter in Fluent NHibernate FluentMappings?

When using auto mappings in Fluent NHibernate, you have the ability to do something like: _configuration = Fluently.Configure(). Database( MsSqlConfiguration.MsSql2000.ConnectionString( @"some connection string") ) .Mappings( m => m.AutoMappings.Add(AutoMap.Assembly...