Code Monkey home page Code Monkey logo

nhibernate / nhibernate-core Goto Github PK

View Code? Open in Web Editor NEW
2.1K 168.0 920.0 92.19 MB

NHibernate Object Relational Mapper

Home Page: https://nhibernate.info

License: GNU Lesser General Public License v2.1

HTML 0.01% C# 95.76% JavaScript 0.14% GAP 0.18% Batchfile 0.05% PowerShell 0.03% Shell 0.02% TSQL 3.77% Visual Basic .NET 0.06%
nhibernate c-sharp nhibernate-developers linq orm dotnet dotnet-core dotnet-core2 object-relational-mapper criteria-api

nhibernate-core's People

Contributors

amroel avatar ayende avatar bahusoid avatar cremor avatar csharper2010 avatar darioquintana avatar dependabot[bot] avatar eamonhetherton avatar fabiomaulo avatar flukefan avatar fredericdelaporte avatar ggeurts avatar gliljas avatar hazzik avatar jkeyser avatar julian-maughan avatar lillo42 avatar lnu avatar maca88 avatar ngbrown avatar oskarb avatar patearl avatar phatcher avatar pleasantd avatar pleasantsolutions avatar rbirkby avatar renovate[bot] avatar rjperes avatar rogerkratz avatar willholley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nhibernate-core's Issues

NH-3348 - Allow many-to-one using not-null foreign-key while using inverse=false on the one-side

Stefan Agner created an issue — 6th December 2012, 13:07:33:

My goal is to control the relation using the set (the one-side, hence the inverse=false), while maintaining the not null property on the foreign key (since I want to make sure there are never any children without parents, so legancy code not using NHibernate can't corrupt my database) while still being able to get the parent from an arbitrary child.

The mapping looks like this:

    <class name="Parent">
      <id name="Id">
        <generator class="identity"/>
      </id>
      <property name="Name"/>
      <set name="Children" inverse="false">
        <key column="ParentId" not-null="true" />
        <one-to-many class="Child"/>
      </set>
    </class>

    <class name="Child">
      <id name="Id">
        <generator class="identity"/>
      </id>
      <many-to-one name="Parent" column="ParentId" />
      <property name="Name"/>
    </class>

When I try to persist a new Parent object with some children, I get an exception: "not-null property references a null or transient value Model.Child.Parent"

When I'm using not-null="false" instead, it works. But since NHibernate 3, NHibernate inserts the Parent first and the Children afterwards, so there is no need to check the Parent property on the Child for not-null. I even would make this property read-only, since it has more an informative character for code reading/update those classes...

Using MS SQL 2008 R2 and Visual Studio 2012 and .NET 4.0.

NH-2619 - Dialect Scope for Named SQL Query

Ricardo Peres created an issue — 4th April 2011, 6:41:27:

It would be useful to allow named SQL queries (the element) to be scoped for a given dialect, or set of dialects, like it is for .
Something like this:

NH-1954 - Version of CreateFilter that return ICriteria

Marko Podgorsek created an issue — 3rd September 2009, 0:06:11:

Current method: IQuery CreateFilter(object collection, string queryString);

For consistency of nhibernate library there should also be a function with definition:

ICriteria CreateCriteriaFilter(object collection);
ICriteria CreateCriteriaFilter<T>(T collection) where T : class;

Criteria queries are better than HQL, because you get at least a little bit of intellisense and compiler time checking.
I would like that my projects are written 100% in Criteria Queries and I would not like to mix Criteria Queries with HQL.
It's just not consistent and that's not good in the long run.

NH-1217 - Order of inserts is wrong when

Dave Warry created an issue — 30th November 2007, 5:06:49:

See http://forum.hibernate.org/viewtopic.php?t=981614 for a better laid-out description.

We have a Root object which has a collection of Nodes. Some of these may be members of a directed graph, so each Node has a collection of a its outgoing edges and its incoming Edges.

Ideally, we would like to save the whole lot by just saving the Root instance, but this is failing. Ideally, I think it should do the following:

  1. insert Root
  2. insert Node1
  3. insert Node2
  4. insert Edge1

NH is trying to do this:

  1. insert Root
  2. insert Node1
  3. insert Edge1
  4. insert Node2
  5. update Edge1 with FK to Node2

Unfortunately, the Edge-Node FKs have not-null constraints, so the initial insert of Edge2 fails.

Obviously, there are various work-arounds, but none of them feel right:

  • get rid of not null constraints

  • flush the session before creating the Edge object

  • disable the cascades and save the instances explicitly

  • (on Oracle) make the not-null constraint deferred so it is only checked a the end of the transaction. Unfortunately, this project is using SQL Server, so this isn't an option.

A simple test case project is attached.


Dario Quintana added a comment — 9th February 2008, 13:06:06:

Not so easy to fix, the cascade is going processing childs recursively, then, first save the Edge and later save the Node2.
If you remove the not-null from Edge properties, the tests get pass.

Tests added to fix later. Revision 3283.


Fabio Maulo added a comment — 9th February 2008, 13:18:57:

inverse=true mean Parent-Child relationship.

Do you have a Child with two different Parent ?


Karl Chu added a comment — 21st April 2008, 19:45:50:

I made an attempt to fix this some time ago as well, and it is not an easy fix. Basically, NHibernate saves the entities in a depth-first sequence. To fix this we need to change it to breath-first. Postponing indefinitely.


Dario Quintana added a comment — 15th July 2008, 6:19:42:

postponed


Alexander Zaytsev added a comment — 7th January 2016, 3:42:34:

You need to add cascade on the edge's side as well.


Alexander Zaytsev added a comment — 7th January 2016, 3:58:15:

Another option is to move cascade of one of the relations to edge's side

NH-3514 - Support for Math.Min() and Math.Max() in LINQ

Oskar Berggren created an issue — 21st August 2013, 16:10:05:

The Linq provider should support queries containing Math.Min() and Math.Max(). In the SQL they should use the GREATEST/LEAST functions where available, otherwise a case-clause. Probably greatest/least can be used as function names for the dialects to register.

NH-3708 - Implement One Shot Delete For Inverse Collections

Ricardo Peres created an issue — 23rd September 2014, 10:04:16:

Currently, one-shot-delete (entity.Collection.Clear()) does not work with inverse collections. For performance reasons (single DELETE), it would be useful to have it working also for inverse collections, since these are the most common. Whoever implements this needs to pay attention to filters.

Need to look out for:

  • Filters and Where restrictions
  • Delete events will not be raised on each item of the collection because we won't be looping through them
  • Deletes entities in the collection need to be evicted from the session
  • What happens if the collection is not loaded?
  • If we have composite ids, we cannot use DELETE FROM ... WHERE id IN (,,,)

Alexander Zaytsev added a comment — 25th September 2014, 1:44:07:

Events will not be raised

why?


Ricardo Peres added a comment — 25th September 2014, 7:18:34:

<~hazzik>: what I mean is: if we are to issue a DELETE command instead of going through all of the loaded collection items and deleting one by one, no delete event will be fired upon them. Same if the collection is not loaded.
This seem tricky to me, I guess that's why nobody implemented it.


Alexander Zaytsev added a comment — 25th September 2014, 7:28:45:

Moved comment to description:)

NH-1040 - property-ref on joined-subclasses should work or error

Jerome Haltom created an issue — 12th June 2007, 7:46:30:

In reference to NH-887.

property-ref does not seem to be supported when referring to joined-subclass mappings. A solution is to introduce a duplicate property in the joined subclass (Property2) with insert and update set to false, and use property-ref to refer to that property.

NHibernate should at least error when encountering a property-ref pointing to a joined-subclass, if not support it.

Whomever decides this issue, just rename the bug.

NH-3080 - Validate Oracle Sequences from different Schema/User

wrathburn created an issue — 5th March 2012, 21:53:13:

I am working on a project where I want to validate an Oracle schema via another Oracle user account. Everything works except for validating sequences. The query in the Oracle8iDialect for getting the sequences is "select sequence_name from user_sequences" which only works if you are logged in as that schema owner. Would it be better to use something like "select sequence_name from sys.all_sequences where owner = upper('" + Environment.Properties["default_schema"] + "'". This would require a default_schema specified in the configuration but would return a correct set of sequences as long as the asking schema as SELECT permissions granted to the schema.

The fix for my project is I use a custom Oracle Dialect which can be seen in the attached file.

Unable to set command_timeout on Update

Hi,

I am trying to set the command_timeout but it looks like it only affects Insert actions. Can you confirm if I am using the fluent API correct or if it is not related to fluent API.

A) I set the command_timeout to 10 seconds (just for testing the real value should be higher)
B) I set a trigger on the table to do a wait

  1. I do a Insert and that times out after 10 seconds
  2. I do a Update and that times out after 30 seconds (default NHibernate value I assume)
  3. I tested the same with delete and the timeout is also 30 seconds

Shouldn't the command_timeout affect all commands?

Thanks
Mikkel

Below is the example I used:

I setup a factory like so:

A)

var factory = Fluently.Configure()
    .Database(MsSqlConfiguration.MsSql2008.ConnectionString(conString).ShowSql())  
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>())
    .ExposeConfiguration(cfg => cfg.SetProperty(NHibernate.Cfg.Environment.CommandTimeout, "10"))
    .BuildSessionFactory();

B)
On my test table I added a trigger (INSERT, UPDATE and DELETE) that just have "WAITFOR DELAY '00:00:45'"

  1. When I do a Insert:
using (var session = factory.OpenSession())
{
    using (var transaction = session.BeginTransaction())
    {
        var test = new Testtable() { Time = DateTime.Now };
        session.Save(test);
        transaction.Commit();
    }
}

This times out after 10 seconds.

  1. When I do an Update:
using (var session = factory.OpenSession())
{
    using (var transaction = session.BeginTransaction())
    {
        var test = session.Get<Testtable>(1); //Id = 1 is in the DB
        test.Time = DateTime.Now;
        session.Update(test);
        transaction.Commit();
    }
}

This timeout after 30 seconds

NH-3220 - Nhibernate query trace shows columns repeated 20 times

pranav kedare created an issue — 15th July 2012, 22:19:52:

We are getting a fairly weird issue for flat tables when we are using session.Query (LINQ) for getting results.

I am attaching one of the example here where this is happening intermittently.

Instead of selecting just required columns, it is selecting 800 columns (same columns repeated three times with diff alias) so we are bringing that much data. Can we check why this is happening.

Please see Nhibernate trace query attached. (jllnhibernatequery.txt)
Mapping file : JournalLineItem.hbm.xml

Hibernate config:

  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.driver_class">UI.DAS.BusinessEntities.OracleDataClientDriverExtended, UI.DAS.BusinessEntities</property>
      <property name="connection.connection_string">Myconnection;</property>
      <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
      <property name="use*proxy*validator">false</property>
      <property name="show_sql">true</property>
      <property name="current*session_context_class">thread*static</property>
      <mapping assembly="UI.DAS.BusinessEntities"/>
    </session-factory>
  </hibernate-configuration>

Query :

        public IEnumerable<IBalanceByAsset> GetBalanceByInstrument(OurCriteria criteria)
        {
            IEnumerable<IBalanceByAsset> asset = default(IEnumerable<IBalanceByAsset>);
            using (IStatelessSession session = StatelessSession)
            {
                

                var query = (from journal in session.Query<IJournalLineItem>()
                                 .Where(BuildPredicate(criteria))
                             group journal by new
                             {
                                 journal.BusinessDate,
                                 ((JournalLineItem)journal).BusinessPeriodTypeColumn,

                                 journal.FunctionalCurrencyId,
                                 journal.TransactionalCurrencyId,

                                 journal.FunctionalCurrencyCode,
                                 journal.TransactionalCurrencyCode,

                                 journal.SubledgerAccountId,
                                 journal.SubLedgerAccountName,
                                 journal.GeneralLedgerAccountId,
                                 journal.GeneralLedgerAccountName,
                                 ((JournalLineItem)journal).GeneralLedgerAccountTypeColumn,

                                 journal.MasterBookId,

                                 journal.CPNodeId,
                                 ((JournalLineItem)journal).InternalOrExternalColumn,
                                 journal.PartnerMCUCode,
                                 journal.SAPCompanyCodeId,
                                 journal.SAPCostCentreCode,
                                 journal.ProductSubTypeId,
                                 journal.ReportingMCUCode,

                                 journal.InstrumentId,
                                 journal.InstrumentName,
                                 journal.AlternateInstrument
                             }
                                 into groupedJournal
                                 select new BalanceByAsset()
                                 {
                                     AccountType = groupedJournal.Key.GeneralLedgerAccountTypeColumn.ToEnumFromDbValue<AccountTypeEnum>(),

                                     BusinessDate = groupedJournal.Key.BusinessDate,
                                     BusinessPeriodType = groupedJournal.Key.BusinessPeriodTypeColumn.ToEnumFromDbValue<BusinessPeriodTypeEnum>(),

                                     FunctionalCurrencyId = groupedJournal.Key.FunctionalCurrencyId,
                                     FunctionalCurrencyCode = groupedJournal.Key.FunctionalCurrencyCode,

                                     TransactionalCurrencyId = groupedJournal.Key.TransactionalCurrencyId,
                                     TransactionCurrencyCode = groupedJournal.Key.TransactionalCurrencyCode,

                                     SubledgerAccountId = groupedJournal.Key.SubledgerAccountId,
                                     SubLedgerAccountName = groupedJournal.Key.SubLedgerAccountName,
                                     GeneralLedgerAccountId = groupedJournal.Key.GeneralLedgerAccountId,
                                     GeneralLedgerAccountName = groupedJournal.Key.GeneralLedgerAccountName,

                                     MasterBookId = groupedJournal.Key.MasterBookId,

                                     CPNodeId = groupedJournal.Key.CPNodeId,
                                     InternalOrExternal = groupedJournal.Key.InternalOrExternalColumn.ToEnumFromDbValue<PartyInternalOrExternalEnum>(),
                                     PartnerMCUCode = groupedJournal.Key.PartnerMCUCode,
                                     SAPCompanyCodeId = groupedJournal.Key.SAPCompanyCodeId,
                                     SAPCentreSAPCostCentreId = new EnterpriseIdentifier { Id = groupedJournal.Key.SAPCostCentreCode },
                                     ProductSubTypeId = groupedJournal.Key.ProductSubTypeId,
                                     ReportingMCUCode = groupedJournal.Key.ReportingMCUCode,

                                     InstrumentId = groupedJournal.Key.InstrumentId,
                                     InstrumentName = groupedJournal.Key.InstrumentName,
                                     AlternateInstrumentReference = groupedJournal.Key.AlternateInstrument,
                                     FunctionalCurrencyAmount = groupedJournal.Sum(j => j.FunctionalCurrencyAmount),
                                     Amount = groupedJournal.Sum(j => j.Amount)
                                 });

                asset = query.ToList();
            }
           
            return asset;
        }

[email protected] added a comment — 17th July 2012, 20:13:29:

The following workaround is applied to avoid tracing repeated columns:

Split the query and transformation into two.

a. Query:

   using (IStatelessSession session = StatelessSession) 
            { 
                 

                var query = (from journal in session.Query<IJournalLineItem>() 
                                 .Where(BuildPredicate(criteria)) 
                             group journal by new 
                             { 
                                 journal.BusinessDate, 
                                 ((JournalLineItem)journal).BusinessPeriodTypeColumn, 

                                 journal.FunctionalCurrencyId, 
                                 journal.TransactionalCurrencyId, 

                                 journal.FunctionalCurrencyCode, 
                                 journal.TransactionalCurrencyCode, 

                                 journal.SubledgerAccountId, 
                                 journal.SubLedgerAccountName, 
                                 journal.GeneralLedgerAccountId, 
                                 journal.GeneralLedgerAccountName, 
                                 ((JournalLineItem)journal).GeneralLedgerAccountTypeColumn, 

                                 journal.MasterBookId, 

                                 journal.CPNodeId, 
                                 ((JournalLineItem)journal).InternalOrExternalColumn, 
                                 journal.PartnerMCUCode, 
                                 journal.SAPCompanyCodeId, 
                                 journal.SAPCostCentreCode, 
                                 journal.ProductSubTypeId, 
                                 journal.ReportingMCUCode, 

                                 journal.InstrumentId, 
                                 journal.InstrumentName, 
                                 journal.AlternateInstrument 
                             } 
                                 into groupedJournal 
                                 select new 
                                 { 
                                        groupedJournal.Key,
 
                                     FunctionalCurrencyAmount = groupedJournal.Sum(j => j.FunctionalCurrencyAmount), 
                                     Amount = groupedJournal.Sum(j => j.Amount) 
                                 }); 

var rawResult = query.ToList();

b. Transform by reading rawResult.


Oskar Berggren added a comment — 12th November 2012, 21:05:18:

As I understand it the correct results are returned, so it's a performance issue. With a workaround. So it's not Critical.

NH-1953 - Support Future for collection filters

Marko Podgorsek created an issue — 2nd September 2009, 6:57:10:

Currently, Future<> doesn't work on CreateFilter

I have a class:

public class User
{
      public virtual IList<Tag> Tags { get; protected set; }
}

public class Tag .... //not important

Mapping for User -- the Tags part:

<bag lazy="true" name="Tags" table="USER_TAG">
      <key>
        <column name="ID_USER" />
      </key>
      <many-to-many class="BeriMe.Biz.Domain.Tag, BeriMe.Biz, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
        <column name="ID_TAG" />
      </many-to-many>
</bag>

If I do this:

User u = db.Get<User>(5);

var t = db.CreateFilter(u.Tags, "")
                .SetFirstResult(4)
                .SetMaxResults(3)
                .Future<Tag>();    //If I say List<Tag>() it works OK.

            foreach (var x in t) { } //crash

Error:
NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type 'Antlr.Runtime.MismatchedTreeNodeException' was thrown. [].

Error from log:
ERROR NHibernate.Hql.Parser - MismatchedTreeNodeException(3!=2)


Fabio Maulo added a comment — 2nd September 2009, 23:20:15:

I think that was never supported.

NH-3541 - Future queries of Criteria API/QueryOver are batched separately from other query methods

Massimiliano Alberti created an issue — 28th September 2013, 8:09:10:

I was interested in batching together (through the use of .Future<>()) a CreateSQLCriteria (so a native SQL query) with a QueryOver query, but I've discovered that the two are batched separately (so two distinct commands are sent to the SQL). I've done some tests and it seems there are two queues:

  • HQL, Native SQL, LINQ queue
  • Criteria API/QueryOver queue

I've built an nunit to show it (I have done all the 10 possible X-Y tests, I trust that the X-X tests (HQL+HQL) will work, but I've only tested .Future(), not .FutureValue(), and without parameters in the query)

NH-3740 - Querying Any Property Type

Ricardo Peres created an issue — 28th November 2014, 10:31:54:

When we have an entity with an association of type , it is not possible to query by a specific implementation class. For example, the following query fails:


session.Query<MyEntity>().Where(x => x.AnyProperty is SomeImplementation).ToList();

The same in HQL:


session.CreateQuery("from MyEntity x where x.AnyProperty.class = SomeImplementation").List<MyEntity>();

Before someone asks, this won't work too:


session.CreateQuery("from MyEntity x where x.AnyProperty.class = 'SomeImplementation'").List<MyEntity>();

NHibernate will issue a query without properly wrapping the type name:


WHERE AnyPropertyClass = SomeImplementation

And it should use the proper meta-value, for example, in the case of a string:


WHERE AnyPropertyClass = 'SomeImplementation'

Or a number:


WHERE AnyPropertyClass = 1

A test will follow shortly.


Alexander Zaytsev added a comment — 28th November 2014, 10:43:00:

<~rjperes> can you also add tests with AnyProperty as reference to a parent class of some hierarchy? Like UnionSubclass and JoinedSubclass?

NH-1558 - sorting tables, columns and constraints in schema export script file

Hielke Hoeve created an issue — 4th November 2008, 2:24:37:

Sometimes when we make an export of our data model using NHibernate's SchemaExport we get a create and drop sql file in which the tables and constraints are ordered in a different way. It is then hard to diff the new files with the old ones and see which column has been added, removed or renamed. I have made a patch which allows for a file in which tables, constraints and the table columns are sorted alphabetically.

The patch does not alter the inner workings of the exporter, it only sorts the tables, columns and constraints when they are written to the sql file. I'm not sure if this will introduce any problems, for example certain key insert statements needing to be in an exact order, but maybe this ordering can be enabled/disabled using a property in Configuration.


Hielke Hoeve added a comment — 4th November 2008, 2:27:29:

Obviously the title should also contain "table".: sorting tables, columns and constraints in schema export


Fabio Maulo added a comment — 8th November 2008, 13:43:43:

mmmmm make that change outside SchemaExport is to dangerous.
BTW the improv is interesting and useful.


Hielke Hoeve added a comment — 8th November 2008, 14:33:28:

We have been using an external sorting machine (doing the same as above) for huge applicatinos for over a year now without problems. Found it a good idea so posted it here, sorry to see that your think it is not a good idea for in nhiberate. Can provide a part of the code as example if needed.


Fabio Maulo added a comment — 10th November 2008, 9:52:42:

where you had read that somebody said that "it is not a good idea" ?
What I said is clear: "the improv is interesting and useful"


Hielke Hoeve added a comment — 10th November 2008, 11:06:27:

I said "sorry to see that your think it is not a good idea for in nhiberate", with that I meant for inside nhibernate.
(Since you said it was too dangerous to make the change inside SchemaExport)


Tuna Toksoz added a comment — 4th February 2009, 13:21:04:

Why is it too dangerous to make it in Configuration?

NH-2547 - Ordering by the same column more than once throws an error

ryanhaugh created an issue — 23rd February 2011, 13:49:44:

I'm using MVC and have an action that returns different action results based on a given parameter (for example it may return a web page or excel document). The same IQueryable object will be used regardless of the output type. When an excel document is returned, the IQueryable object is simply given to the excel file generator. When a web page is returned, the IQueryable will be passed to the view where a third-party grid uses the IQueryable object to display the data.

The problem is that I want the object to already be sorted by the time it gets to the excel file generator so I add an OrderBy when generating the query (I don't want to have to deal with adding specific column ordering in the action because I would need to do it for every action that I use this and I want a generic solution). However, the third-party grid has built-in sorting capabilities and when I choose to sort by the column that was used in the OrderBy when creating the query I get an error saying the same column name appears more than once in the order by clause. Since the grid control can also handle paging I don't want to simply return a List or something and lose the IQueryable object.

It would be nice if the Linq provider removed the first instance of a column in the order by if the same column is added again.

I'm using MS SQL Server 2005, .NET 4.0.


Ricardo Peres added a comment — 2nd September 2014, 22:35:54:

I don't think this can/should be fixed... IMO, adding two order by clauses is an error


Alexander Zaytsev added a comment — 3rd September 2014, 1:49:57:

I think that the case is valid, but I'm lowering the priority


Alexander Zaytsev added a comment — 3rd September 2014, 1:50:07:

Also, what exception is thrown?


Oskar Berggren added a comment — 7th September 2014, 14:35:34:

Shouldn't a Linq OrderBy() simply(?) override any previous OrderBy() provided no skip/take or similar is between them?


Alexander Zaytsev added a comment — 7th September 2014, 21:53:08:

It should.


Ricardo Peres added a comment — 7th September 2014, 22:19:11:

In Entity Framework the last call to OrderBy is the one that is applied. No complaints about multiple ones.


Alexander Zaytsev added a comment — 7th September 2014, 23:09:17:

It is much more complicated, when ThenBy involved. As OrderBy/ThenBy do stable sorting.

So the following test passes:

var list = new List<T>();
for (int i = 0; i < 100; i<ins></ins>)
{
    list.Add(new T(r.Next(1, 10), r.Next(1, 10), r.Next(1, 10)));
}

var cs = list.OrderBy(x => x.B)
    .OrderBy(x => x.A)
    .ThenBy(x => x.A)
    .ThenBy(x => x.C)
    .ThenBy(x => x.A)
    .ThenBy(x => x.B)
    .OrderBy(x => x.A)
    .ToList();

var cs2 = list.OrderBy(x => x.A)
    .ThenBy(x => x.C)
    .ThenBy(x => x.B);

Assert.That(cs, Is.Ordered.By("A"));
Assert.True(cs.SequenceEqual(cs2));

NH-3561 - Date time generic hql functions

Himanshu Kodwani created an issue — 28th October 2013, 11:37:13:

Nhibernate : HQL has few date time functions but sometimes these are not enough. I just ran into a problem when I tried searching for "Notifictions" that need to be repeated weekly, based on its "StartDate". I needed a function that could return day of the week from "StartDate" column, but there was no generic function or way to do this without writing SQL or HQL specific to the DB I am using. However, I am testing my application on one DB system but in production I'll be using it on another based on my clients choice. This will create more complications later.
I found out that MySQL has multitude of DateTime functions, if NHibernate team could just replicate these in a Generic way for all the DB dialects, it will add huge value to its query apis.
I am attaching a list of available mysql DateTime functions as attachment.


Oskar Berggren added a comment — 28th October 2013, 22:17:20:

You can add your own implementations of the functions you need by subclassing the dialects you want to use. That way you can write HQL and make it work on all dialects where you can find SQL expressions to implement the function.

If you provide such implementations for a decent number of the most popular dialects, it could probably be included in the NHibernate source code.

NH-3395 - Expand of subcollection with WCF data services should initialize expanded collection

Alexander Zaytsev created an issue — 13th February 2013, 1:57:17:


var query = from o in db.Orders
            select new ExpandedWrapper<Order, ISet<OrderLine>>
            {
                ExpandedElement = o,
                ProjectedProperty0 = o.OrderLines,
                Description = "OrderLine",
                ReferenceDescription = "OrderLine"
            };

var result = query.ToList();
Assert.That(result.Count, Is.EqualTo(830));
Assert.That(NHibernateUtil.IsInitialized(result<0>.ExpandedElement.OrderLines), Is.True);
Assert.That(NHibernateUtil.IsInitialized(result<0>.ProjectedProperty0), Is.True);
Assert.That(result<0>.ExpandedElement.OrderLines, Is.SameAs(result<0>.ProjectedProperty0));

It should be transformed to something like that:


var query = session.CreateQuery("select o from Order o left join fetch o.OrderLines")
   .SetResultTransformer(Transformers.DistinctRootEntity)
   .List<Order>()
   .Select(o => new ExpandedWrapper<Order, ISet<OrderLine>>
   {
       ExpandedElement = o,
       ProjectedProperty0 = o.OrderLines,
       Description = "OrderLine",
       ReferenceDescription = "OrderLine"
   });


Oskar Berggren added a comment — 13th February 2013, 7:38:52:

Assert.That(result<0>.ExpandedElement.OrderLines, Is.SameAs(result<0>.ProjectedProperty0));

Should it really? Perhaps the ProjectedProperty should be regarded more as an equal to the List instance generated by e.g. ToList() on queries - i.e. that list itself is not tracked by NH and adding/removing from it does not imply that NHibernate will update the database.

Consider if we have employed the encapsulate-collections pattern. We would have an o._orderLines as the true collection, o.OrderLines would still be mapped, but with access="*field". It would return IEnumerable or some ReadOnlyCollection wrapper. If the above assert holds true, the list in ProjectedProperty would now provide a (unexpected?) backdoor to bypass domain logic.

So perhaps we should instead add the opposite assert, to ensure that it will never be the same collection? In this case, if the user expects it to be the same, their intended changes aren't saved and they will quickly realize their mistake.

Do you know how L2EF behaves?


Alexander Zaytsev added a comment — 13th February 2013, 12:53:49:

I think you are right.

No, I dont know about L2EF

NH-3122 - ThreadStaticSessionContext does not allow multidatabase

felice Pollano created an issue — 20th April 2012, 14:39:18:

The ThreadStaticSessionContext accept a binding of the session without taking care of which session factory it belong. As a result, you cant use current context when using multiple databases. It would be nice to have a contextual session paired with the session factory.
I don't provide any unit test because by looking at the ThreadStaticSessionContext is very easy to see the described behavior.

NH-1910 - Support of Stored Procedures Output parameters in MS SQL

Gediminas Guoba created an issue — 3rd August 2009, 8:04:20:

Hello,

It would be great if NHibernate would support output parameters of Stored Procedures.


Fabio Maulo added a comment — 4th August 2009, 7:40:46:

Why you thinking that it is not supported ?


Gediminas Guoba added a comment — 4th August 2009, 7:58:40:

Could you please provide any samples?

I have simple scenario: to receive list from item 1 to item 10 and also return total items count using out parameter of stored procedure.
To get my custom query I use:
IQuery query = Session.GetNamedQuery("CustomSPQuery");

Then I set required parameters:
query.SetInt32("param1", 15);

Execute query:
IList list = query.List();

How to get output parameter value in this point?

Thanks in advance!


Fabio Maulo added a comment — 20th August 2009, 7:33:48:

For pagination we use another solution...
btw for this issue can you provide a sample ? (SP + mappings)

NH is supporting SP with output parameters and I would check if your case is supported or not.


tejal mandal added a comment — 9th February 2015, 4:48:39:

Is output parameter supported in nhibernate ...Please provide sample of store procedure and table mapping

NH-2581 - FormatException "String was not recognized as a valid Boolean" exception message should be more helpful

kkozmic created an issue — 16th March 2011, 18:11:07:

That's just an example of an exception thrown in general when conversion error occurred when trying to read/write a property.

Below is the stack trace:

Test method bla bla threw exception:
NHibernate.Exceptions.GenericADOException: could not load an entity: <Foo.Bar#15>[SQL: some SQL here] ---> System.FormatException: String was not recognized as a valid Boolean.

at System.Boolean.Parse(String value)
at System.String.System.IConvertible.ToBoolean(IFormatProvider provider)
at System.Convert.ToBoolean(Object value)
at NHibernate.Type.BooleanType.Get(IDataReader rs, Int32 index)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Type.AbstractType.Hydrate(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Persister.Entity.AbstractEntityPersister.Hydrate(IDataReader rs, Object id, Object obj, ILoadable rootLoadable, String<][> suffixedPropertyColumns, Boolean allProperties, ISessionImplementor session)
at NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i, Object obj, String instanceClass, EntityKey key, String rowIdAlias, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session)
at NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, EntityKey key, LockMode lockMode, String rowIdAlias, EntityKey optionalObjectKey, Object optionalObject, IList hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable<] persisters, EntityKey[> keys, Object optionalObject, EntityKey optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode<] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[> keys, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, String optionalEntityName, Object optionalIdentifier, IEntityPersister persister)
--- End of inner exception stack trace ---
at NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, String optionalEntityName, Object optionalIdentifier, IEntityPersister persister)
at NHibernate.Loader.Entity.AbstractEntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId)
at NHibernate.Loader.Entity.AbstractEntityLoader.Load(Object id, Object optionalObject, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session)
at NHibernate.Event.Default.DefaultRefreshEventListener.OnRefresh(RefreshEvent event, IDictionary refreshedAlready)
at NHibernate.Event.Default.DefaultRefreshEventListener.OnRefresh(RefreshEvent event)
at NHibernate.Impl.SessionImpl.FireRefresh(RefreshEvent refreshEvent)
at NHibernate.Impl.SessionImpl.Refresh(Object obj)

In general I would expect to see at least the following:

  1. Which class property was the problem.
  2. What can I do about it ( something like "Your mapping says the property Bla is of type bool. However the value in the database was of type string and could not be converted to bool. Make sure your mapping corresponds to the database schema or use custom IUserType to provide custom conversion between bool and string").

Fabio Maulo added a comment — 23rd March 2011, 14:54:32:

  1. The message "<Foo.Bar#15>" has not only the class but even the POID.
  2. ok, we will check

kkozmic added a comment — 10th January 2012, 6:02:47:

Any update on this one?

NH-2625 - Implement Dialect Scope for Subselect

Ricardo Peres created an issue — 5th April 2011, 4:26:25:

It would be great if the new <subselect /> functionality could be scoped to a specific dialect or set of dialects, like <database-object />.

NH-2286 - Use providerName attribute of <connectionStrings>

Jason Dentler created an issue — 14th August 2010, 7:04:26:

IMO, this is the logic extension of our current discussion around https://nhibernate.jira.com/browse/NH-1378, but is valid even without it.

For example, a user specifies a standard connection string in App.Config like this.

A user also sets the NH property connection.connectionstringname to "db".

With this information, we can choose some sensible defaults for driver and dialect according to the providerName attribute.

Ignoring the boring technical details, this is the Microsoft-prescribed way to specify what type of DB you are using. This is one small thing we can do to ease the transition from Microsoft's data access tech to NHibernate.

I'll start a thread on the dev-list to discuss what the defaults should be, and follow up with a patch once the dust has settled.


Fabio Maulo added a comment — 14th August 2010, 11:09:26:

but then we have to create a map between the providerName and the appropriate NH's Drive.

NH-766 - N+1 load on query fetching a many-to-one

kirkwylie created an issue — 23rd October 2006, 6:42:42:

This is being promoted from something I posted on the NHibernate forums.

Using NHibernate 1.0.2.0 against Oracle 9.

I'm working with an existing schema which isn't using surrogate keys, and I have a composite key of the form:

<class name="CalculatedRating" ...>
  <composite-id>
    <key-property name="EffectiveDate" column="EFFECTIVE_DATE"/>
    <key-many-to-one name="FdeOrganization" column="ORGANIZATION_ID" .../>
  </composite-id>
...
</class>

Using this query:

    from CalculatedRating cr
         inner join fetch cr.FdeOrganization fdeOrg
         left join fetch fdeOrg.Attributes as attribute
         inner join fetch attribute.AttributeType
    where cr.EffectiveDate =
          (select max(cr2.EffectiveDate)
           from CalculatedRating cr2
           where cr2.EffectiveDate >= :EffectiveDate)
    order by cr.FdeOrganization.OrgId

NHibernate is quite correctly generating the SQL necessary to completely manifest the CalculatedRating element in a single query. However, after executing that query, it then still proceeds to do the N+1 select on FdeOrganization.

As in this application I'm actually using quite a few cases where I'm successfully using the inner join fetch technique against FdeOrganization, I can only assume that this is a problem related to key-many-to-one rather than many-to-one.

After further investigation, I can establish that Hibernate 3.1.3 exposes the exact same functionality. I'm filing this first against NHibernate since that's where I first discovered it, however, since it affects Hibernate as well it might be better filed against that, and I can do so if needed.


justme84 added a comment — 23rd October 2006, 6:50:29:

Can you supply a small simple NUnit test case?


kirkwylie added a comment — 23rd October 2006, 6:53:38:

I can try to, but extracting one given a relatively proprietary schema (that I had to extract things out of above) might take some time. Given that it affects Hibernate as well, and I'm going to that effort, do you recommend doing that in Hibernate (JUnit) or NHibernate (NUnit)?


justme84 added a comment — 23rd October 2006, 6:54:44:

Hibernate is probably better, once/if it will be fixed in Hibernate I can then port the fix.


kirkwylie added a comment — 23rd October 2006, 7:08:24:

Created Hibernate request http://opensource.atlassian.com/projects/hibernate/browse/HHH-2170 to track.

NOTE 2015-01-11: That link is now https://hibernate.atlassian.net/browse/HHH-2170 /Oskar


torvin added a comment — 5th July 2013, 9:16:05:

Still doesn't work in NH3.3. Any chance that it will be fixed?
I have an entity with composite id, consisting of 2 references to other entities. NH generates tons of SELECTS instead of 2 joins.


Mehrdad added a comment — 10th January 2015, 14:17:37:

Hello, I am also experiencing this problem.

Why is it not confirmed? How can I start helping to fix this ?


Mehrdad added a comment — 11th January 2015, 8:36:40:

I added a test case as was requested a long time ago.
I hope this issue gets addressed as soon as possible.

Also in the test case, I am not forcing a join query because I think being a composite key many to one association, nhibernate should load the association using a join. That said, even forcing a join using join fetch has no effect on the number of queries.

Some links that seem to be related:
http://stackoverflow.com/questions/8256816/nhibernate-select-n1-despite-using-hql-query-with-eager-fetch
https://forum.hibernate.org/viewtopic.php?f=25&t=996445
http://comments.gmane.org/gmane.comp.windows.dotnet.nhibernate.user.general/20763


Oskar Berggren added a comment — 11th January 2015, 20:48:47:

I'm not sure I understand exactly what the issue is. Is there a mismatch between the issue title and the actually description? With the recent description of the test case, it sounds like the expection is that NH should add joins even when not specified in the query (don't know if I agree), while the issue title implies that a join should be removed?


Mehrdad added a comment — 12th January 2015, 6:14:15:

From the description:
"NHibernate is quite correctly generating the SQL necessary to completely manifest the CalculatedRating element in a single query. However, after executing that query, it then still proceeds to do the N+1 select on FdeOrganization."

The test case is about that, meaning nhibernate is generating two more queries for every OrderedElement in the test case, even if I specify "join fetch e.Parent join fetch e.Element" in the query; It does produce a join query then, but it goes on to generate extra queries as well. I am not sure if that is necessary to hydrate the complete OrderedElement object, since -correct me If I'm mistaken- the join query result already contains what is necessary for creation of an OrderedElement object.

NH-2903 - Support CreateFilter for a collection of components

felice Pollano created an issue — 30th September 2011, 15:52:36:

NOTE: this is a correction for NH-2902

I have an entity with a list of components ( bag ). Trying to count this collection without loading it by issuing session.CreateFilter( collection,"select count( * )") does not work and return the following error:

NHibernate.QueryException : collection of values in filter: this [select count(*)]

Similar situation happens if we try to page the collection with:

session.CreateFilter(result.Children,string.Empty)
                        .SetFirstResult(first)
                        .SetMaxResults(count)
                        .List();

with this error:

NHibernate.QueryException : collection of values in filter: this []

I can overtake the first problem with Linq2NH by selecting the count of the collection in the query, but I have no idea on how to achieve the second, this is the reason I'm trying to use CreateFilter. If there is a better way to page a children collection I would love to tnow how. If there isn't, I attached a unit test to show the problem.


Julian Maughan added a comment — 24th February 2012, 15:47:53:

This is not currently supported, so I have changed this issue from a Bug to an Improvement for a future version.


Ricardo Peres added a comment — 19th November 2014, 21:54:29:

An alternative approach: https://weblogs.asp.net/ricardoperes/querying-an-uninitialized-collection-with-nhibernate

NH-3137 - NHibernate Linq First() does not parametrize TOP criteria (MsSql2008)

Morten Brix Pedersen created an issue — 30th April 2012, 14:38:18:

Using a query such as:

var firstRow = session.Query().Where(x => x.SomePredicate).First();

The generated SQL has "TOP 1", but the 1 should be parametrized using @p0.

This is a performance improvement since the server can re-use the same execution plan for queries.

NH-2866 - NHibernate.TestDatabaseSetup Improvements

Patrick Earl created an issue — 5th September 2011, 4:20:03:

  • Make it determine the database to recreate from the connection string.
  • Add an option to the build menu to (re)create the empty database.
  • Add documentation to the contributor guide on how to (re)create database.

NH-3254 - DateTime vs Date/Timestamp in Oracle

stigchristensen created an issue — 31st August 2012, 7:03:22:

The Oracle dialect maps DateTime to DbType.DateTime. This is a good choice if you are using the Oracle timestamp.

When using Oracle Date this is not at good mapping because Oracle will not use the index resulting in slow queries. If you instead use the DbType.Date (NHibernate.Type.DateType) the index will work but the time part would be removed. A Oracle Date has a time part.

To fix this we need another date type like the custom one posted here.

https://groups.google.com/group/nhusers/browse_thread/thread/1e68220bcafcf28c


edmaher added a comment — 2nd December 2014, 2:28:04:

This is actually a Major issue.
In Oracle10g Dialect derived from Oracle9i Dialect, the DateTime type is mapped to TIMESTAMP(4) which is unexpected. I suspect that many users will have databases using column type DATE and expecting DateTime to work.
The way that this causes a problem is not immediately obvious and hard to locate.
I am wondering what the rationale is to use TIMESTAMP(4) in NHibernate, perhaps for timestamp comparison capability ?


stigchristensen added a comment — 9th June 2017, 11:30:18:

see fix here

https://github.com/stigc/FixOracleDatesNotUsingIndex

NH-3603 - NHibernate cannot save an object to a JSON column in Postgres

Dru Sellers created an issue — 25th February 2014, 22:20:37:

I have implemented a custom UserType that will take a given object, serialize it into JSON via Newtonsoft - and then try to save it into the database. My usertype uses the NHibernateUtil.String type to configure the db parameter and stuff.

It reads just fine, its the writing that is the issue.

NOTE: I have this working via raw NPGSQL dll, so I have found the issue to be in NHibernate.


Dru Sellers added a comment — 25th February 2014, 22:25:56:

Sample Test Case


Dru Sellers added a comment — 26th February 2014, 0:58:45:

Found a part of the issue in Npgsql - npgsql/npgsql#168

NH-2735 - Allow query on .id special accessor on <any /> mappings in Linq

andrei.alecu created an issue — 24th May 2011, 4:00:27:

Querying a property defined with an mapping by its id needs to use the special .class and .id properties defined by HQL.

Not having a way to access .id makes it impossible to translate queries such as the following to Linq:

from ToyBox t where t.Shape.class = Square and t.Shape.id = 1 (note that there's currently a bug with .class at NH-2734)

Note that accessing the identifier property mapped as .Id (non lowercase) does not work, the HQL query parser complains that there's an access to an unmapped property .Id.

My current workaround is to define this extension method as a custom linq generator:

    public class ImplicitIdGenerator : BaseHqlGeneratorForMethod
    {
        public ImplicitIdGenerator()
        {
            this.SupportedMethods = new[] { ReflectionHelper.GetMethodDefinition<object>(x => x.ImplicitId()) };
        }

        public override HqlTreeNode BuildHql(
            MethodInfo method,
            Expression targetObject,
            ReadOnlyCollection<Expression> arguments,
            HqlTreeBuilder treeBuilder,
            IHqlExpressionVisitor visitor)
        {
            return treeBuilder.Dot(visitor.Visit(arguments[0]).AsExpression(), treeBuilder.Ident("id"));
        }
    }

    public static class NhibernateLinqExtensions
    {
        public static object ImplicitId(this object what)
        {
            throw new NotImplementedException("Used by NHibernate linq with <any> mappings.");
        }
    }

I believe the special .id property may also be used in other circumstances when the name of the property used for the identifier is not known.

I'm not sure if this is the most elegant implementation, but this code lets you do this:

var results = session.Query().Where(x=> /** class constraint, see NH-2328 **/ && x.Shape.ImplicitId() == 1);


Alexander Zaytsev added a comment — 21st May 2012, 19:25:48:

Pleas check if DynamicLinq solves this problem.

NH-3533 - Make Restrictions.In usable

Fernando Mato Mira created an issue — 20th September 2013, 9:37:07:

As described in NH-3136, the mapping of Restrictions.In is not satisfactory.

I currently resorted to create a temporary table with IDs and selecting using SQL when there are many such IDs.

While this provides adequate performance, it requires enumerating every field actually used in the mapping for the selected tables, which is unacceptable.

A solution would be to extend HQL to allow an IN clause that can access the temporary table.

Alternatively, the Restrictions.In mapping should be reimplemented so that when there are too many values, the query is translated into a temporary table creation, select, and temporary table deletion, like I have to do explicitly.

NH-1886 - When having a discriminator and a many-to-one association on the same column in a superclass insertion fails

rberens created an issue — 15th July 2009, 2:03:43:

When having a discrimator and a many-to-one association on the same column in a superclass insertion fails.
Consider the following example:

<class name="PaymentType" table="PAYMENT_TYPE"/>
    <id name="Id" type="Int64" column="PAYMENT_TYPE_ID">
        <generator class="native"/>
    </id>
    <property name="Name" column="NAME"/>
</class>

<class name="IPayment" table="PAYMENT">
    <id name="Id" type="Int64" column="PAYMENT_ID">
        <generator class="native"/>
    </id>
    <discriminator column="PAYMENT_TYPE_ID" type="Int64"/>
    <many-to-one name="PaymentType" table="PAYMENT_TYPE" column="PAYMENT_TYPE_ID"/>
    <property name="Amount" column="AMOUNT"/>
    ...
    <subclass name="CreditCardPayment" discriminator-value="CREDIT">
        ...
    </subclass>
    <subclass name="CashPayment" discriminator-value="CASH">
        ...
    </subclass>
    <subclass name="ChequePayment" discriminator-value="CHEQUE">
        ...
    </subclass>
</class>

As you can see the column PAYMENT_TYPE_ID is used twice: both in the discriminator and many-to-one association. This is obviously wrong and when trying to insert a CreditCardPayment the insertion fails in the Dehydrate method in the AbstractEntityPersister, when trying to assign the id. This is because too many parameters are counted (PaymentTypeId is counted twice and therefore the id index is one too high and violates the array bounds.
As said before having the PAYMENT_TYPE_ID twice is obviously wrong. It is not detected however when reading the mapping file and therefore very hard to debug. It took me hours of debugging and examining the NHibernate sources to find out, whereas a simple message during reading of the mapping file would have made it clear in a second.

Note that there may be more of such combinations, where a column can be specified twice. Therefore a general check after having read the mapping file could save a lot of time.

NH-3751 - Primary Key and Unique key names

Josep created an issue — 26th January 2015, 13:08:43:

NH creates Primary key names using this pattern:
PK*TableName*RandomNumber

Ex:
PK*SW_Users*3214EC07FE5A24FC

Unique key has same name format:
UQ*TableName*RandomNumber

Ex:
UQ*SW_Users*6DE3D4BDDE67FCCC.

Why is not possible to add PK and UK manually in mapping files as index can be done?


Ricardo Peres added a comment — 26th January 2015, 16:37:33:

OK, but how do you imagine this functionality? For example, are you thinking of new XML attributes that would go in the and elements?


Josep added a comment — 8th February 2015, 14:46:07:

I guess a new mapping attribute should be more natural. For example:

<id
  	name="Id"
  	column="Id"
  	generator="native"
  	type="System.Int32" 
  	key-name="PK*SW*Users"  		<---
  >
</id>
<property
  	name="UserName"
  	column="UserName"
  	length="255"
  	not-null ="true"
  	type="Sdk.Data.NHExtensions.CryptedString, Sdk.Data"
  	unique-key="true" 
  	unique-key-name="UQ*SW*Users"		<----
  >		
</property>

Cheers

Multiple named check constraints

Currently it's possible to specify multiple check constraints for an entity by just joining each constraint together with "AND","OR", etc. and passing the concatenated string to mapping.CheckConstraint().

However, this results in a single check constraint in the database. For cases where there are multiple constraints it would be very useful to be able to specify them separately so that they appear as multiple check constraints within the database. This would make it much more obvious why an insert has failed as the check constraint would be much more specific.

Would this be something that can be easily implemented?

NH-2325 - problems with StartsWith / EndsWith / Contains / Substring / IndexOf

Hung Tran created an issue — 7th September 2010, 3:18:55:

My mapping is

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" default-access="field.camelcase-underscore" default-lazy="true" default-cascade="none" >
    <class name="Order" dynamic-update="true" dynamic-insert="true">
        <id name="Id" unsaved-value="-1" type="Int64" length="18">
            <generator class="native"/>
        </id>
        <property name="Code" type="String" length="255" index="IX*CODE*D1436656544BAE8D"/>
        <property name="Comment" type="String" length="255"/>
        <bag name="Lines" fetch="subselect" lazy="false" cascade="all-delete-orphan">
            <key column="Order"/>
            <one-to-many class="OrderLine"/>
        </bag>
    </class>
    <class name="OrderLine" dynamic-update="true" dynamic-insert="true">
        <id name="Id" unsaved-value="-1" type="Int64" length="18">
            <generator class="native"/>
        </id>
        <many-to-one name="Product" class="Product" column="Product" index="IX*FK*95888E80952904EB" lazy="proxy"/>
        <property name="Quantity" type="Int32"/>
        <property name="RetailPrice" type="Decimal"/>
    </class>
    <class name="Product" dynamic-update="true" dynamic-insert="true">
        <id name="Id" unsaved-value="-1" type="Int64" length="18">
            <generator class="native"/>
        </id>
        <property name="Code" type="String" length="255" index="IX*CODE*952904EB544BAE8D"/>
        <property name="CostPrice" type="Decimal"/>
        <property name="Description" type="String" length="255"/>
        <property name="Name" type="String" length="255"/>
    </class>
</hibernate-mapping>

LINQ:

(from o in db.AsQueryable<Order>() where o.Code.Contains("001") select o).ToList();

SQL:

select order0*.[ID] as ID1_0_, order0_.[CODE] as CODE2_0_, order0_.[COMMENT] as COMMENT3_0_ from [ORDER] order0_ where order0*.[CODE] like ('%'+@p0+'%');@p0 = '001' [Type: String (4000)]

LINQ:

(from o in db.AsQueryable<Order>() where o.Code.StartsWith("001") select o).ToList();

SQL:

select order0*.[ID] as ID1_0_, order0_.[CODE] as CODE2_0_, order0_.[COMMENT] as COMMENT3_0_ from [ORDER] order0_ where order0*.[CODE] like (@p0+%');@p0 = '001' [Type: String (4000)]

LINQ:

(from o in db.AsQueryable<Order>() where o.Code.EndsWith("001") select o).ToList();

SQL:

select order0*.[ID] as ID1_0_, order0_.[CODE] as CODE2_0_, order0_.[COMMENT] as COMMENT3_0_ from [ORDER] order0_ where order0*.[CODE] like ('%'+@p0);@p0 = '001' [Type: String (4000)]

=> The where clause in all cases above should be where order0_.[CODE] like @p0', and @p0 = '%001%' / @p0 = '001%' / @p0 = '%001', the one will gain more performance when the query above run many times.
=> StartsWith/EndsWith/Contains methods can reuse the same SQL Execution Plan by database engine

LINQ:

(from o in db.AsQueryable<Order>() where o.Code.Substring(2, 3) == "000" select o).ToList()

SQL:

select order0*.[ID] as ID1_0_, order0_.[CODE] as CODE2_0_, order0_.[COMMENT] as COMMENT3_0_ from [ORDER] order0_ where (substring(order0_.[CODE], @p0, @p1) is null) and (@p2 is null) or substring(order0*.[CODE], @p0, @p1)=@p2;@p0 = 2 [Type: Int32 (0)], @p1 = 3 [Type: Int32 (0)], @p2 = '000' [Type: String (4000)]

=> The where clause should be where length(order0*.[CODE]) >= (@p0 + @p1) and substring(order0*.[CODE], :p0, :p1) == :p2


Fabio Maulo added a comment — 7th September 2010, 9:19:26:

  1. The Linq-provider is available only in NH3.
  2. Ok in case of constant-parameter

Oskar Berggren added a comment — 5th April 2012, 16:02:33:

@tdhung80 Could you please check if these problems persist in 3.3.0CR1?


Alexander Zaytsev added a comment — 23rd January 2013, 3:06:20:

I think it is possible to make new ExpressionType to handle this.

NH-2750 - NHibernate Listeners Configuration Improvement

stefan.sedich created an issue — 28th May 2011, 21:50:16:

I was looking at the new configuration (which I do quite like) in NH 3.2, but noticed the lambda based configuration does not
allow a nice way to configure listeners, I have created a patch fort his and attached it to the email, the new configuration would now be possible like so:

new Configuration()
.DataBaseIntegration(db =>
{
db.Dialect();
db.BatchSize = 15;
})
.Listeners(l =>
{
l.AppendListener(ListenerType.Load, new FooListener());
});

NH-1811 - Expose helper method to get underlying instance from a proxy

leemhenson created an issue — 4th June 2009, 9:16:47:

Patch adds support for:

var underlyingInstance = NHibernateProxyHelper.Unproxy(proxy);

It simply extracts the proxy initialization logic out of NHibernateUtil.GetClass() and puts in a client-usable form.


leemhenson added a comment — 4th June 2009, 9:17:28:

Patch for trunk.


Fabio Maulo added a comment — 4th June 2009, 10:24:02:

For real you have all you need, and much more, in IPersistenceContext
((ISessionImplementor)session).PersistenceContext.Unproxy
or
((ISessionImplementor)session).PersistenceContext.UnproxyAndReassociate

A simple NHibernateProxyHelper.Unproxy(proxy) is unsafe, btw its usage is under user responsibility.


Fabio Maulo added a comment — 4th June 2009, 10:27:32:

Please attach a test case is you want it for NH2.1.0


leemhenson added a comment — 8th June 2009, 6:47:32:

Ah I wasn't aware of those methods on PersistenceContext. That's fine, although could we extend the Unproxy method there to allow you specify that you want the proxy initialized? e.g.

Unproxy(object maybeProxy)
{
    return Unproxy(maybeProxy, false);
}

Unproxy(object maybeProxy, bool initialize)
{
    INHibernateProxy proxy = maybeProxy as INHibernateProxy;
    if (proxy != null)
    {
        ILazyInitializer li = proxy.HibernateLazyInitializer;
        if (li.IsUninitialized && !initialize)
            throw new PersistentObjectException("object was an uninitialized proxy for " + li.PersistentClass.FullName);

        return li.GetImplementation(); // unwrap the object 
    }
    else
    {
        return maybeProxy;
    }
}

(Patch attached for that change)

When you say Unproxy is unsafe, what do you mean? It's kind of a power-user method anyway, something to call when you really have to, not an everyday thing.

Transformers.AliasToBean: Value cannot be null. Parameter name: key

Just test upgraded from version 3.3.1 to 5.0.0 from nuget. Some of our test cases are broken after upgrade and they all seems to be making use of Transformers.AliasToBean. I am not able to open latest code in Visual Studio 2015 so at the moment can't do further debugging.

at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters, IResultTransformer forcedResultTransformer)
at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes)
at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results)
at NHibernate.Impl.CriteriaImpl.List(IList results)
at NHibernate.Impl.CriteriaImpl.List[T]()
at NHibernate.Impl.CriteriaImpl.Subcriteria.List[T]()`

NH-3421 - Indexes for associations to non physical classes/tables

Phillip Conrad created an issue — 16th March 2013, 20:34:41:

Scenario:

  • Table per subclass
  • UpdateSchema

NHibernate doesn't generate foreign key contraints for non physical classes (abstract classes and other classes with subclasses). This behavior is logical because there is no specific table, which can be referenced. But to improve the performance we can generate an index in this scenario.

I have changed the behavior of the schema generator in the attachment.
Subject: Configuration::GenerateSchemaUpdateScript(..)
It's works fine with MySQL2008 and MySQL5.5.

NH-3287 - support for partial uri's in UriType.cs

Carel Blumenstock created an issue — 7th October 2012, 18:04:17:

added UriKind.RelativeOrAbsolute to emable partial uri's, have them and ran into the lacking UriKind.RelativeOrAbsolute

war:

    public object NullSafeGet(IDataReader rs, string[] names, object owner)
    {
        //We get the string from the database using the NullSafeGet used to get strings 
        string uriString = (string)NHibernateUtil.String.NullSafeGet(rs, names<0>);

        //And save it in the Uri object. This would be the place to make sure that your string 
        //is valid for use with the System.Uri class, but i will leave that to you
        Uri result = new Uri(uriString);
        return result;
    }

    public object DeepCopy(object value)
    {
        //We deep copy the uri by creating a new instance with the same contents
        if (value == null) return null;
        return new Uri(value.ToString());
    }

ist:

    public object NullSafeGet(IDataReader rs, string[] names, object owner)
    {
        //We get the string from the database using the NullSafeGet used to get strings 
        string uriString = (string)NHibernateUtil.String.NullSafeGet(rs, names<0>);

        //And save it in the Uri object. This would be the place to make sure that your string 
        //is valid for use with the System.Uri class, but i will leave that to you
        Uri result = new Uri(uriString, UriKind.RelativeOrAbsolute);
        return result;
    }

    public object DeepCopy(object value)
    {
        //We deep copy the uri by creating a new instance with the same contents
        if (value == null) return null;
        return new Uri(value.ToString(), UriKind.RelativeOrAbsolute);
    }

Carel Blumenstock added a comment — 7th October 2012, 18:06:05:

in UriType.cs

NH-3278 - Enhancement of Informix dialect for supporting System.Guid datatype

Aikson created an issue — 27th September 2012, 12:54:40:

In the attachment you can find all changed source files for a support of System.GUID datatypes in Informix databases (tested with Informix 11.50 and Client SDK 3.50TC/FC9). The support was added in 3.2 and 3.3.1 and works in both versions


Aikson added a comment — 27th September 2012, 12:56:02:

Adding source files


Alexander Zaytsev added a comment — 27th September 2012, 15:48:15:

Why CHAR(36)? Other dialects/drivers are using CHAR(16) to store guids


NH-3187 - Ability to filter a bag with where in mapping by inherited columns

Alexander Zaytsev created an issue — 13th June 2012, 18:15:34:

  <class name="Person">
    <id name="Id" generator="guid.comb" />
    <property name="Name"/>
    <property name="IsDeleted"/>
    <joined-subclass name="Policeman">
      <key column="PersonId" />
      <many-to-one name="Station" column="StationId" />
    </joined-subclass>
  </class>

  <class name="Station">
    <id name="Id" generator="guid.comb" />
    <bag name="Policemen" where="IsDeleted = 0">
      <key column="StationId" />
      <one-to-many class="Policeman"/>
    </bag>
  </class>

Accessing to station.Policemen generates wrong sql:

    SELECT
        policemen0_.StationId as StationId1_,
        policemen0_.PersonId as PersonId1_,
        policemen0_.PersonId as Id0_0_,
        policemen0_1_.Name as Name0_0_,
        policemen0_1_.IsDeleted as IsDeleted0_0_,
        policemen0_.StationId as StationId1_0_ 
    FROM
        Policeman policemen0_ 
    inner join
        Person policemen0_1_
            on policemen0_.PersonId=policemen0_1_.Id 
    WHERE
        (
            policemen0_.IsDeleted = 0 -- should be policemen0_1_
        ) 
        and policemen0_.StationId=@p0;

Alexander Zaytsev added a comment — 13th June 2012, 18:28:36:

Test commited

NH-2579 - Make error messages helpful and indicate what the problem is and how to go about fixing it

kkozmic created an issue — 16th March 2011, 16:32:55:

I'm trying to save an object to the database and I get the following exception:
https://gist.github.com/873531

It is absolutely unhelpful and gives me no indication whatsoever of what the issue is.

I find it a general problem with NHibernate that it just lets the low level failures make their ways up the stack and lose all the contextual information so I end up with ArgumentException, ArgumentNullException, or like here ArgumentOutOfRange exception and I'm scratching my head trying to figure out which part of my massive mapping may be the cause.

I haven't looked into the code but I'm pretty sure NHibernate knows what ManyToOne relation it was trying to persist, so it should tell me that. It should also help me figure out why the argument was out of range, and what area of my mapping is the most likely cause of that.


kkozmic added a comment — 16th March 2011, 17:19:46:

I figured out what the cause of my issue was. I had three properties that were wrongly mapped to a single column in the database. I think that's something that NHibernate can easily figure out by just inspecting the mapping. Actually I don't think that's ever the desirable behavior so it could probably throw an exception much sooner - when inspecting the mapping.


Fabio Maulo added a comment — 17th March 2011, 5:24:08:

column duplication is possible... you can use insert="false" and so on..
probably we have already a warning.
btw we should check the situation and throw a specific exception with the probable cause instead a ArgumentOutOfRange without meaning.


kkozmic added a comment — 10th January 2012, 6:00:55:

@fabio

Yeah, I agree.

In this case I didn't have insert="false", so I guess NHibernate should treat situations like this: where it sees multiple insertable properties mapped to a single column it should throw a helpful exception suggesting a solution.

NH-1148 - Allow insert="false", update="false" for many-to-one relation based on multi-column

Sylvain Gherold created an issue — 26th September 2007, 0:27:27:

Hello,

It would be very usefull to be able to define insert="false", update="false" in a many-to-one relationship at a "column level" in case of multiple columns.
For example :

    <many-to-one name="Rating" class="InstrumentRating">
      <column name="INSTRUMENTID" update="false" insert="false"/>
      <column name="RATINGSCHEMEID"/>
      <column name="RATINGDATE"/>
    </many-to-one>

Thanks
Sylvain


Sylvain Gherold added a comment — 26th September 2007, 4:12:09:

Here is a contribution to implement this improvement:
NH-1138 Contrib.zip
Changes can be identified by search the following tag
"//SGH : Adding support of updateable, insertable at columnlevel"


Fabio Maulo added a comment — 6th June 2009, 16:58:18:

The attached file does not contain a single test.
The patch can't be applied in NH without a specific test case.

NH-3670 - Dynamic component should allow generic dictionary

Ricardo Peres created an issue — 19th August 2014, 15:11:42:

Currently, the <dynamic-component> mapping only allows properties of type IDictionary. It should also support IDictionary<string, object>.


Ricardo Peres added a comment — 20th August 2014, 10:40:44:

Pull request: #305
Created additional generic (with IDictionary<string, object>) tests for all test cases related to dynamic-component (NH-1796, NH-1039, NH-3571 and NH-2664)

Possible breaking change: mapping a dynamic component with a Hashtable property instead of an IDictionary as documented is no more supported.

Question: Unique() constraint that allow NULLS ?

There is an interesting situation when is needed that a UNIQUE CONSTRAINT to take into account a WHERE clause.
eg for SQL Server 2008:

CREATE UNIQUE NONCLUSTERED INDEX idx_yourcolumn_notnull
ON YourTable(yourcolumn)
WHERE yourcolumn IS NOT NULL;

There is a topic on StackOverflow regards this situation :
http://stackoverflow.com/questions/767657/how-do-i-create-a-unique-constraint-that-also-allows-nulls

So I'm wondering if there is some way of acheiving conditional unique constrains with fluent nhibernate.

NH-3402 - Refactor ThreadLocalSessionContext

Ricardo Peres created an issue — 17th February 2013, 11:02:55:

Currently ThreadLocalSessionContext does not inherit from CurrentSessionContext, and as such, it is not possible to use it with the static methods CurrentSessionContext.Bind() and Unbind(). However, unexperienced developers may be fooled into that, and may find themselves in trouble.
If it is considered that this implementation offers advantages over ThreadStaticSessionContext, it would be useful to properly implement it so that it can be used; otherwise, just remove it or mark it as obsolete.


Ricardo Peres added a comment — 20th February 2014, 9:46:28:

This is a quick fix also, just inherit from CurrentSessionContext.


Daniel A. Schilling added a comment — 20th February 2014, 15:00:01:

That wouldn't actually work - the behavior of static methods doesn't change based on what inherits it. ThreadLocalSessionContext.Bind(session) works one way, while CurrentSessionContext.Bind(session) works another way - and those differences in behavior are important to those classes. Simply changing ThreadLocalSessionContext to inherit from CurrentSessionContext would actually make it more confusing for developers. Since ThreadLocalSessionContext still needs the behavior contained in its own Bind method, now it would have two static Bind methods (one from CurrentSessionContext), and developers would still have to know call the correct one - ThreadLocalSessionContext.Bind(session).

I think it would be better it there weren't these static methods at all. Instead of doing this:


    ThreadLocalSessionContext.Bind(session);
    session = ThreadLocalSessionContext.Unbind(factory);

... I think this would be better:


    session.BindAsCurrentSession();
    session = factory.UnbindCurrentSession();

This would require adding Bind and Unbind methods to the ICurrentSessionContext interface (and a HasBind method would be nice, too), and implementing some new methods on ISession and ISessionFactory. But you would no longer have to change which static methods your code called depending on how you configured Configuration.CurrentSessionContext<T>() - just setting that one configuration value would take care of all the rest.


Daniel A. Schilling added a comment — 20th February 2014, 15:23:11:

The new methods for ISession and ISessionFactory could be implemented as extension methods, minimizing the impact of this change. Something like...


    public static void BindAsCurrentSession(this ISession session)
    {
        var factoryImplementor = (ISessionFactoryImplementor)session.SessionFactory;
        var context = factoryImplementor.CurrentSessionContext;

        context.Bind(session); // TODO: add this new `Bind` method to ICurrentSessionContext
    }

    public static ISession UnbindCurrentSession(this ISessionFactory factory)
    {
        var factoryImplementor = (ISessionFactoryImplementor)factory;
        var context = factoryImplementor.CurrentSessionContext;

        return context.Unbind(factory); // TODO: add this new `Unbind` method to ICurrentSessionContext
    }


Ricardo Peres added a comment — 20th February 2014, 17:12:03:

Daniel:
I guess you have never used ThreadLocalSessionContext. I know very well about the Bind method, the problem is when you declare ThreadLocalSessionContext by fluent configuration or .config file: NHibernate throws an exception because the base class is not what it expects.
The static methods are standard on all SessionContext classes, I know they are not inherited, but that's the way they were designed.


Daniel A. Schilling added a comment — 20th February 2014, 17:23:05:

I've been using ThreadLocalSessionContext for my unit tests and WebSessionContext for my MVC web application against NHibernate 3.3.3.4001 with no issues. What exception do you receive? Code that expects a specific base class rather than simply expecting something that implements ICurrentSessionContext is not written correctly.


Ricardo Peres added a comment — 20th February 2014, 17:33:55:

You are binding directly on ThreadLocalSessionContext instead of CurrentSessionContext.
The code that throws the exception is CurrentSessionContext.Bind(session). This allows better decoupling, you do not have to know the exact class you are using.


Daniel A. Schilling added a comment — 20th February 2014, 19:07:57:

Correct, using CurrentSessionContext.Bind(session) when the context has been configured to be ThreadLocalSessionContext does not work. But merely changing the inheritance tree will not fix that. Changing ThreadLocalSessionContext's base class would end up amounting to a complete re-write of ThreadLocalSessionContext in order to make CurrentSessionContext.Bind(session) work for it, if it ends up being possible at all.

I think the changes I've suggested (#comment-31861) would be the ideal long-term fix - though they would be breaking changes for anybody that has implemented their own ICurrentSessionContext. But anybody (myself, for one) attempting to leverage different kinds of ICurrentSessionContexts within the same solution will have to work around this problem, so it would be nice if the fix was baked into NHibernate.

To develop a workaround for this issue, you can think of ICurrentSessionContext and related classes as an incomplete example of the (http://en.wikipedia.org/wiki/Strategy_pattern) design pattern. You can fill in the missing pieces (Bind and Unbind) to build a completed strategy interface yourself:


    public interface ICurrentSessionContextStrategy
    {
        void Configure(Configuration config);
        void Bind(ISession session);
        ISession Unbind(ISessionFactory factory);
    }

    public abstract class BaseCurrentSessionContextStrategy<T> : ICurrentSessionContextStrategy
        where T : ICurrentSessionContext, new()
    {
        public void Configure(Configuration config)
        {
            config.CurrentSessionContext<T>();
        }

        public abstract void Bind(ISession session);
        public abstract ISession Unbind(ISessionFactory factory);
    }

    public class CurrentSessionContextStrategy<T> : BaseCurrentSessionContextStrategy<T>
        where T : CurrentSessionContext, new()
    {
        public override void Bind(ISession session)
        {
            CurrentSessionContext.Bind(session);
        }

        public override ISession Unbind(ISessionFactory factory)
        {
            return CurrentSessionContext.Unbind(factory);
        }
    }

    public class ThreadLocalSessionContextStrategy : BaseCurrentSessionContextStrategy<ThreadLocalSessionContext>
    {
        public override void Bind(ISession session)
        {
            ThreadLocalSessionContext.Bind(session);
        }

        public override ISession Unbind(ISessionFactory factory)
        {
            return ThreadLocalSessionContext.Unbind(factory);
        }
    }

Then you create a single instance of whichever strategy you want and use it to handle both the configuration and the binding/unbinding.


    public static class CurrentSessionContextStrategy
    {
        public static ICurrentSessionContextStrategy Strategy { get; set; }
    }

When configuring NHibernate:


    CurrentSessionContextStrategy.Strategy = new ThreadLocalSessionContextStrategy();
    var config = new Configuration();
    // ... other configuration code...
    CurrentSessionContextStrategy.Strategy.Configure(config);
    // ... now build your session factory ...

When binding:


    var session = factory.OpenSession();
    CurrentSessionContextStrategy.Strategy.Bind(session);

When unbinding:


    var session = CurrentSessionContextStrategy.Strategy.Unbind(factory);
    if (session != null)
        session.Dispose();

This isn't exactly the way I'm handling it in my code, but as far as dealing with this particular issue, it's the same general idea.

That's a fair chunk of code for a workaround, and I wish it wasn't necessary. I vote for adding Bind, Unbind, and maybe HasBind directly to the ICurrentSessionContext interface. Static methods are frequently a source of coupling problems. The best way to fix this high-coupling issue is to make these static methods be instance methods instead. Even my workaround has a static Strategy property which assumes that every session factory in the currently running application uses the same session context strategy. That's probably a safe assumption, until you run into a scenario where it's not. Static methods are unyielding. Their behavior cannot be changed, so they must be used carefully and judiciously - only in places where you're sure no one needs to swap in different behavior. For CurrentSessionContext.Bind(session), that is an incorrect assumption.


Ricardo Peres added a comment — 20th February 2014, 23:28:54:

Daniel:
This thread has grown much more than it's worth! :-)
To cut the story short, all that it takes is:


public class ThreadLocalSessionContext : CurrentSessionContext
{
	private ThreadLocal<ISession> _session = new ThreadLocal<ISession>();

	public ThreadLocalSessionContext(Engine.ISessionFactoryImplementor factory)
	{
	}

	protected override ISession Session
	{
		get { return (this._session.Value); }
		set { this._session.Value = value; }
	}
}

And that's it. No major refactoring, no nothing. We keep things as they are and simply allow ThreadLocalSessionContext to be used like all_the_other context classes.


Ricardo Peres added a comment — 21st February 2014, 11:30:40:

Pull request: #254


Ricardo Peres added a comment — 8th May 2014, 11:35:45:

I think this can be included.


Ricardo Peres added a comment — 13th August 2014, 12:09:09:

New pull request created, as requested: #292


Alexander Zaytsev added a comment — 12th August 2016, 4:40:09:

Move unresolved improvements and new features with minor and trivial priorities to 4.2.0


Frédéric Delaporte added a comment — 13th June 2017, 22:13:48:

ThreadLocalSessionContext main advantage over ThreadStaticSessionContext is the support of multiple session factories used within the same context (thread). With NH-4032, it will lose that advantage.

Other points are its ability to open a session "on the fly" instead of yielding null as all other contextes, and a sort of "auto-cleanup" when user bind a new session without having unbound the previous one. Those abilities do not make much sens without some documented behaviors it does not actually implements: at least auto-closing session on transaction end, and the forbidden usage of session without transactions.


Frédéric Delaporte added a comment — 20th June 2017, 20:24:14:

Now that NH-4032 is merged, do we obsolete that ThreadLocalSessionContext, or do we finish its implementation?


Alexander Zaytsev added a comment — 14th September 2017, 1:47:17:

Move issues from 4.2 to 5.0


Alexander Zaytsev added a comment — 14th September 2017, 1:57:24:

Move minor and trivial improvements to 5.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.