From: <te...@us...> - 2008-11-22 18:56:06
|
Revision: 3918 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3918&view=rev Author: tehlike Date: 2008-11-22 18:56:04 +0000 (Sat, 22 Nov 2008) Log Message: ----------- Finalizing NH-1569 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2008-11-17 21:54:06 UTC (rev 3917) +++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2008-11-22 18:56:04 UTC (rev 3918) @@ -312,7 +312,7 @@ if (settings.IsAutoValidateSchema) { // TODO NH : Schema validator not ported yet - // new SchemaValidator(cfg, settings).validate(); + new SchemaValidator(cfg, settings).Validate(); } if (settings.IsAutoDropSchema) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-11-22 22:22:04
|
Revision: 3920 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3920&view=rev Author: fabiomaulo Date: 2008-11-22 21:31:16 +0000 (Sat, 22 Nov 2008) Log Message: ----------- Removed TODO because done Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2008-11-22 20:38:45 UTC (rev 3919) +++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2008-11-22 21:31:16 UTC (rev 3920) @@ -311,7 +311,6 @@ } if (settings.IsAutoValidateSchema) { - // TODO NH : Schema validator not ported yet new SchemaValidator(cfg, settings).Validate(); } if (settings.IsAutoDropSchema) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2010-01-06 22:12:03
|
Revision: 4912 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4912&view=rev Author: ayenderahien Date: 2010-01-06 22:11:57 +0000 (Wed, 06 Jan 2010) Log Message: ----------- Changing throwing indexer to TryGetValue Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2010-01-06 21:41:19 UTC (rev 4911) +++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2010-01-06 22:11:57 UTC (rev 4912) @@ -465,14 +465,10 @@ public IEntityPersister GetEntityPersister(string entityName) { - try - { - return entityPersisters[entityName]; - } - catch (KeyNotFoundException) - { - throw new MappingException("No persister for: " + entityName); - } + IEntityPersister value; + if (entityPersisters.TryGetValue(entityName, out value) == false) + throw new MappingException("No persister for: " + entityName); + return value; } public IEntityPersister TryGetEntityPersister(string entityName) @@ -484,14 +480,10 @@ public ICollectionPersister GetCollectionPersister(string role) { - try - { - return collectionPersisters[role]; - } - catch (KeyNotFoundException) - { + ICollectionPersister value; + if(collectionPersisters.TryGetValue(role, out value) == false) throw new MappingException("Unknown collection role: " + role); - } + return value; } public ISet<string> GetCollectionRolesByEntityParticipant(string entityName) @@ -979,14 +971,10 @@ public FilterDefinition GetFilterDefinition(string filterName) { - try - { - return filters[filterName]; - } - catch (KeyNotFoundException) - { + FilterDefinition value; + if(filters.TryGetValue(filterName,out value)==false) throw new HibernateException("No such filter configured [" + filterName + "]"); - } + return value; } public ICollection<string> DefinedFilterNames This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-05-10 17:39:53
|
Revision: 5808 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5808&view=rev Author: fabiomaulo Date: 2011-05-10 17:39:47 +0000 (Tue, 10 May 2011) Log Message: ----------- Improved GetImplementors caching results for a given entityOrClassName Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2011-05-10 16:57:24 UTC (rev 5807) +++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2011-05-10 17:39:47 UTC (rev 5808) @@ -3,6 +3,7 @@ using System.Data; using System.Runtime.Serialization; using System.Text; +using System.Linq; using Iesi.Collections.Generic; using NHibernate.Cache; @@ -29,6 +30,7 @@ using NHibernate.Util; using Environment=NHibernate.Cfg.Environment; using HibernateDialect = NHibernate.Dialect.Dialect; +using IQueryable = NHibernate.Persister.Entity.IQueryable; namespace NHibernate.Impl { @@ -133,6 +135,7 @@ [NonSerialized] private readonly SQLFunctionRegistry sqlFunctionRegistry; [NonSerialized] private readonly Dictionary<string, ResultSetMappingDefinition> sqlResultSetMappings; [NonSerialized] private readonly UpdateTimestampsCache updateTimestampsCache; + [NonSerialized] private readonly IDictionary<string, string[]> entityNameImplementorsMap = new ThreadSafeDictionary<string, string[]>(new Dictionary<string, string[]>(100)); private readonly string uuid; private bool disposed; @@ -590,6 +593,11 @@ /// </summary> public string[] GetImplementors(string entityOrClassName) { + string[] knownMap; + if(entityNameImplementorsMap.TryGetValue(entityOrClassName,out knownMap)) + { + return knownMap; + } System.Type clazz = null; // NH Different implementation for performance: a class without at least a namespace sure can't be found by reflection @@ -597,13 +605,15 @@ { IEntityPersister checkPersister; // NH Different implementation: we have better performance checking, first of all, if we know the class - // and take the System.Type directly from the persister (className have high probability to be entityName) + // and take the System.Type directly from the persister (className have high probability to be entityName at least using Criteria or Linq) if (entityPersisters.TryGetValue(entityOrClassName, out checkPersister)) { if(!checkPersister.EntityMetamodel.HasPocoRepresentation) { // we found the persister but it is a dynamic entity without class - return new[] { entityOrClassName }; + knownMap = new[] { entityOrClassName }; + entityNameImplementorsMap[entityOrClassName] = knownMap; + return knownMap; } // NH : take care with this because we are forcing the Poco EntityMode clazz = checkPersister.GetMappedClass(EntityMode.Poco); @@ -634,56 +644,58 @@ if (clazz == null) { - return new[] {entityOrClassName}; //for a dynamic-class + knownMap = new[] { entityOrClassName }; + entityNameImplementorsMap[entityOrClassName] = knownMap; + return knownMap; //for a dynamic-class } - List<string> results = new List<string>(); - foreach (IEntityPersister p in entityPersisters.Values) + var results = new List<string>(); + foreach (var q in entityPersisters.Values.OfType<IQueryable>()) { - IQueryable q = p as IQueryable; - if (q != null) + string registeredEntityName = q.EntityName; + // NH: as entity-name we are using the FullName but in HQL we allow just the Name, the class is mapped even when its FullName match the entity-name + bool isMappedClass = entityOrClassName.Equals(registeredEntityName) || clazz.FullName.Equals(registeredEntityName); + if (q.IsExplicitPolymorphism) { - string registeredEntityName = q.EntityName; - // NH: as entity-name we are using the FullName but in HQL we allow just the Name, the class is mapped even when its FullName match the entity-name - bool isMappedClass = entityOrClassName.Equals(registeredEntityName) || clazz.FullName.Equals(registeredEntityName); - if (q.IsExplicitPolymorphism) + if (isMappedClass) { - if (isMappedClass) - { - return new string[] {registeredEntityName}; // NOTE EARLY EXIT - } + knownMap = new[] { registeredEntityName }; + entityNameImplementorsMap[entityOrClassName] = knownMap; + return knownMap; // NOTE EARLY EXIT } + } + else + { + if (isMappedClass) + { + results.Add(registeredEntityName); + } else { - if (isMappedClass) + System.Type mappedClass = q.GetMappedClass(EntityMode.Poco); + if (mappedClass != null && clazz.IsAssignableFrom(mappedClass)) { - results.Add(registeredEntityName); - } - else - { - System.Type mappedClass = q.GetMappedClass(EntityMode.Poco); - if (mappedClass != null && clazz.IsAssignableFrom(mappedClass)) + bool assignableSuperclass; + if (q.IsInherited) { - bool assignableSuperclass; - if (q.IsInherited) - { - System.Type mappedSuperclass = GetEntityPersister(q.MappedSuperclass).GetMappedClass(EntityMode.Poco); - assignableSuperclass = clazz.IsAssignableFrom(mappedSuperclass); - } - else - { - assignableSuperclass = false; - } - if (!assignableSuperclass) - { - results.Add(registeredEntityName); - } + System.Type mappedSuperclass = GetEntityPersister(q.MappedSuperclass).GetMappedClass(EntityMode.Poco); + assignableSuperclass = clazz.IsAssignableFrom(mappedSuperclass); } + else + { + assignableSuperclass = false; + } + if (!assignableSuperclass) + { + results.Add(registeredEntityName); + } } } } } - return results.ToArray(); + knownMap = results.ToArray(); + entityNameImplementorsMap[entityOrClassName] = knownMap; + return knownMap; } public string GetImportedClassName(string className) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |