From: <fab...@us...> - 2009-06-12 15:34:45
|
Revision: 4458 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4458&view=rev Author: fabiomaulo Date: 2009-06-12 15:34:31 +0000 (Fri, 12 Jun 2009) Log Message: ----------- Fix NH-1623 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs trunk/nhibernate/src/NHibernate/Cfg/Environment.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Bytecode/IInjectableCollectionTypeFactoryClass.cs trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/ProductLine.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-06-11 21:49:52 UTC (rev 4457) +++ trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-06-12 15:34:31 UTC (rev 4458) @@ -4,11 +4,12 @@ namespace NHibernate.Bytecode { - public abstract class AbstractBytecodeProvider : IBytecodeProvider, IInjectableProxyFactoryFactory + public abstract class AbstractBytecodeProvider : IBytecodeProvider, IInjectableProxyFactoryFactory, IInjectableCollectionTypeFactoryClass { private readonly IObjectsFactory objectsFactory = new ActivatorObjectsFactory(); protected System.Type proxyFactoryFactory; private ICollectionTypeFactory collectionTypeFactory; + private System.Type collectionTypeFactoryClass = typeof(Type.DefaultCollectionTypeFactory); #region IBytecodeProvider Members @@ -39,7 +40,7 @@ get { return objectsFactory; } } - public ICollectionTypeFactory CollectionTypeFactory + public virtual ICollectionTypeFactory CollectionTypeFactory { get { @@ -48,7 +49,7 @@ try { collectionTypeFactory = - (ICollectionTypeFactory) ObjectsFactory.CreateInstance(typeof (Type.DefaultCollectionTypeFactory)); + (ICollectionTypeFactory) ObjectsFactory.CreateInstance(collectionTypeFactoryClass); } catch (Exception e) { @@ -57,14 +58,6 @@ } return collectionTypeFactory; } - protected set - { - if(value == null) - { - throw new InvalidOperationException("The CollectionTypeFactory can't be null."); - } - collectionTypeFactory = value; - } } #endregion @@ -92,5 +85,36 @@ } #endregion + + #region Implementation of IInjectableCollectionTypeFactoryClass + + public void SetCollectionTypeFactoryClass(string typeAssemblyQualifiedName) + { + if (string.IsNullOrEmpty(typeAssemblyQualifiedName)) + { + throw new ArgumentNullException("typeAssemblyQualifiedName"); + } + System.Type ctf= ReflectHelper.ClassForName(typeAssemblyQualifiedName); + SetCollectionTypeFactoryClass(ctf); + } + + public void SetCollectionTypeFactoryClass(System.Type type) + { + if (type == null) + { + throw new ArgumentNullException("type"); + } + if (typeof(ICollectionTypeFactory).IsAssignableFrom(type) == false) + { + throw new HibernateByteCodeException(type.FullName + " does not implement " + typeof(ICollectionTypeFactory).FullName); + } + if (collectionTypeFactory != null) + { + throw new InvalidOperationException("CollectionTypeFactory in use, can't change it."); + } + collectionTypeFactoryClass = type; + } + + #endregion } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Bytecode/IInjectableCollectionTypeFactoryClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/IInjectableCollectionTypeFactoryClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Bytecode/IInjectableCollectionTypeFactoryClass.cs 2009-06-12 15:34:31 UTC (rev 4458) @@ -0,0 +1,8 @@ +namespace NHibernate.Bytecode +{ + public interface IInjectableCollectionTypeFactoryClass + { + void SetCollectionTypeFactoryClass(string typeAssemblyQualifiedName); + void SetCollectionTypeFactoryClass(System.Type type); + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-06-11 21:49:52 UTC (rev 4457) +++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-06-12 15:34:31 UTC (rev 4458) @@ -55,6 +55,7 @@ public const string DefaultHibernateCfgFileName = "hibernate.cfg.xml"; private string currentDocumentName; + private bool preMappingBuildProcessed; protected IDictionary<string, PersistentClass> classes; // entityName, PersistentClass protected IDictionary<string, NHibernate.Mapping.Collection> collections; @@ -523,12 +524,38 @@ /// </summary> public Mappings CreateMappings(Dialect.Dialect dialect) { + ProcessPreMappingBuildProperties(); return new Mappings(classes, collections, tables, NamedQueries, NamedSQLQueries, SqlResultSetMappings, Imports, secondPasses, propertyReferences, namingStrategy, typeDefs, FilterDefinitions, extendsQueue, auxiliaryDatabaseObjects, tableNameBinding, columnNameBindingPerTable, defaultAssembly, defaultNamespace, dialect); } + private void ProcessPreMappingBuildProperties() + { + if(preMappingBuildProcessed) + { + return; + } + ConfigureCollectionTypeFactory(); + preMappingBuildProcessed = true; + } + + private void ConfigureCollectionTypeFactory() + { + var ctfc = GetProperty(Environment.CollectionTypeFactoryClass); + if(string.IsNullOrEmpty(ctfc)) + { + return; + } + var ictfc = Environment.BytecodeProvider as IInjectableCollectionTypeFactoryClass; + if(ictfc == null) + { + return; + } + ictfc.SetCollectionTypeFactoryClass(ctfc); + } + /// <summary> /// Read mappings from a <see cref="Stream" />. /// </summary> Modified: trunk/nhibernate/src/NHibernate/Cfg/Environment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2009-06-11 21:49:52 UTC (rev 4457) +++ trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2009-06-12 15:34:31 UTC (rev 4458) @@ -158,6 +158,8 @@ public const string DefaultBatchFetchSize = "default_batch_fetch_size"; + public const string CollectionTypeFactoryClass = "collectiontype.factory_class"; + private static readonly Dictionary<string, string> GlobalProperties; private static IBytecodeProvider BytecodeProviderInstance; Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-11 21:49:52 UTC (rev 4457) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-12 15:34:31 UTC (rev 4458) @@ -451,6 +451,7 @@ <Compile Include="Bytecode\AbstractBytecodeProvider.cs" /> <Compile Include="Bytecode\ActivatorObjectsFactory.cs" /> <Compile Include="Bytecode\HibernateByteCodeException.cs" /> + <Compile Include="Bytecode\IInjectableCollectionTypeFactoryClass.cs" /> <Compile Include="Bytecode\IObjectsFactory.cs" /> <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> Modified: trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd =================================================================== --- trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd 2009-06-11 21:49:52 UTC (rev 4457) +++ trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd 2009-06-12 15:34:31 UTC (rev 4458) @@ -102,6 +102,7 @@ <xs:enumeration value="default_entity_mode" /> <xs:enumeration value="use_sql_comments" /> <xs:enumeration value="format_sql" /> + <xs:enumeration value="collectiontype.factory_class" /> </xs:restriction> </xs:simpleType> </xs:attribute> Modified: trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-06-11 21:49:52 UTC (rev 4457) +++ trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-06-12 15:34:31 UTC (rev 4458) @@ -1,6 +1,8 @@ +using System; using NHibernate.Bytecode; using NHibernate.Bytecode.Lightweight; using NUnit.Framework; +using Environment=NHibernate.Cfg.Environment; namespace NHibernate.Test.Bytecode.Lightweight { @@ -71,5 +73,85 @@ Assert.That(e.Message,Text.StartsWith("Failed to create an instance of")); } } + + [Test] + public void NotConfiguredCollectionTypeFactory() + { + // our BytecodeProvider should ever have a CollectionTypeFactory + var bcp = new BytecodeProviderImpl(); + Assert.That(bcp.CollectionTypeFactory, Is.Not.Null); + } + + [Test] + public void SetCollectionTypeFactoryClassByName() + { + string nullName = null; + var bcp = new BytecodeProviderImpl(); + + Assert.Throws<ArgumentNullException>(() => bcp.SetCollectionTypeFactoryClass(nullName)); + Assert.Throws<ArgumentNullException>(() => bcp.SetCollectionTypeFactoryClass(string.Empty)); + Assert.Throws<TypeLoadException>(() => bcp.SetCollectionTypeFactoryClass("whatever")); + } + + [Test] + public void SetCollectionTypeFactoryClassByType() + { + System.Type nullType = null; + var bcp = new BytecodeProviderImpl(); + Assert.Throws<ArgumentNullException>(() => bcp.SetCollectionTypeFactoryClass(nullType)); + Assert.Throws<HibernateByteCodeException>(() => bcp.SetCollectionTypeFactoryClass(GetType()), "should allow only ICollectionTypeFactory type"); + } + + private class NoDefaultCtor: Type.DefaultCollectionTypeFactory + { + public NoDefaultCtor(int something) {} + } + + [Test] + public void InvalidCollectionTypeFactoryCtor() + { + ICollectionTypeFactory ctf; + var bcp = new BytecodeProviderImpl(); + bcp.SetCollectionTypeFactoryClass(typeof (NoDefaultCtor)); + Assert.Throws<HibernateByteCodeException>(() => ctf = bcp.CollectionTypeFactory); + } + + [Test] + public void CollectionTypeFactoryCantChangeAfterUsage() + { + ICollectionTypeFactory ctf; + var bcp = new BytecodeProviderImpl(); + ctf = bcp.CollectionTypeFactory; // initialize the instance + // try to set it + Assert.Throws<InvalidOperationException>(() => bcp.SetCollectionTypeFactoryClass(typeof(Type.DefaultCollectionTypeFactory))); + } + + private class CustomCollectionTypeFactory : Type.DefaultCollectionTypeFactory + { + } + + [Test] + [Explicit("The BytecodeProvider is static and can't be different in the same application.")] + public void AllowCustomCollectionTypeFactoryBeforeBuildFirstMapping() + { + // Allow set of CustomCollectionTypeFactory class after configure BUT before add the first mapping. + // for real we need CustomCollectionTypeFactory before BuildSessionFactory but for possible future + // "mapping-sources" is better to limitate the moment of injectability. + var cfg = TestConfigurationHelper.GetDefaultConfiguration(); + cfg.SetProperty(Environment.CollectionTypeFactoryClass, typeof(CustomCollectionTypeFactory).AssemblyQualifiedName); + Dialect.Dialect dialect = Dialect.Dialect.GetDialect(cfg.Properties); + cfg.CreateMappings(dialect); + Assert.That(Environment.BytecodeProvider.CollectionTypeFactory, Is.TypeOf<CustomCollectionTypeFactory>()); + } + + [Test] + [Explicit("The BytecodeProvider is static and can't be different in the same application.")] + public void WorkAddingMappings() + { + var cfg = TestConfigurationHelper.GetDefaultConfiguration(); + cfg.SetProperty(Environment.CollectionTypeFactoryClass, typeof(CustomCollectionTypeFactory).AssemblyQualifiedName); + cfg.AddResource("NHibernate.Test.Bytecode.Lightweight.ProductLine.hbm.xml", GetType().Assembly); + Assert.That(Environment.BytecodeProvider.CollectionTypeFactory, Is.TypeOf<CustomCollectionTypeFactory>()); + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/ProductLine.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/ProductLine.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/ProductLine.hbm.xml 2009-06-12 15:34:31 UTC (rev 4458) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8" ?> + +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> + + <class entity-name="ProductLine"> + <id name="Id" type="int"> + <generator class="hilo"/> + </id> + <property name="Description" not-null="true" length="200" type="string"/> + + <bag name="Models" cascade="all" inverse="true"> + <key column="productId"/> + <one-to-many class="Model"/> + </bag> + + </class> + + <class entity-name="Model"> + <id name="Id" type="int"> + <generator class="hilo"/> + </id> + + <property name="Name" not-null="true" length="25" type="string"/> + <property name="Description" not-null="true" length="200" type="string"/> + <many-to-one name="ProductLine" column="productId" not-null="true" class="ProductLine"/> + </class> + +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-11 21:49:52 UTC (rev 4457) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-12 15:34:31 UTC (rev 4458) @@ -1901,6 +1901,7 @@ <EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" /> <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> + <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1821\Mappings.hbm.xml" /> <EmbeddedResource Include="TypeParameters\EntityCustomId.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-13 21:18:00
|
Revision: 4459 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4459&view=rev Author: fabiomaulo Date: 2009-06-13 21:17:59 +0000 (Sat, 13 Jun 2009) Log Message: ----------- Fix NH-1834 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/HbmConstants.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/A.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Cfg/HbmConstants.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/HbmConstants.cs 2009-06-12 15:34:31 UTC (rev 4458) +++ trunk/nhibernate/src/NHibernate/Cfg/HbmConstants.cs 2009-06-13 21:17:59 UTC (rev 4459) @@ -8,6 +8,7 @@ public const string nsPrefix = "hbm"; public const string nsKey = nsPrefix + ":key"; public const string nsColumn = nsPrefix + ":column"; + public const string nsFormula = nsPrefix + ":formula"; public const string nsOneToMany = nsPrefix + ":one-to-many"; public const string nsParam = nsPrefix + ":param"; public const string nsIndex = nsPrefix + ":index"; Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-06-12 15:34:31 UTC (rev 4458) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-06-13 21:17:59 UTC (rev 4459) @@ -849,17 +849,30 @@ private void BindColumnsOrFormula(XmlNode node, SimpleValue simpleValue, string path, bool isNullable) { - XmlAttribute formulaNode = node.Attributes["formula"]; - if (formulaNode != null) + var formula = GetFormula(node); + if (formula != null) { - Formula f = new Formula(); - f.FormulaString = formulaNode.InnerText; + var f = new Formula { FormulaString = formula }; simpleValue.AddFormula(f); } else BindColumns(node, simpleValue, isNullable, true, path); } + protected string GetFormula(XmlNode node) + { + XmlAttribute attribute = node.Attributes["formula"]; + if (attribute != null) + { + return attribute.InnerText; + } + else + { + var fcn = node.SelectSingleNode(HbmConstants.nsFormula, namespaceManager); + return fcn != null && !string.IsNullOrEmpty(fcn.InnerText) ? fcn.InnerText : null; + } + } + private void AddManyToOneSecondPass(ManyToOne manyToOne) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/A.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/A.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/A.cs 2009-06-13 21:17:59 UTC (rev 4459) @@ -0,0 +1,14 @@ +namespace NHibernate.Test.NHSpecificTest.NH1834 +{ + public class A + { + public int Id { get; set; } + } + + public class B + { + public int Id { get; set; } + public A A { get; set; } + public A A2 { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/Fixture.cs 2009-06-13 21:17:59 UTC (rev 4459) @@ -0,0 +1,49 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1834 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + var a = new A {Id = 1}; + var a2 = new A {Id = 2}; + var b = new B {Id = 1}; + + using (ISession session = base.OpenSession()) + { + session.Save(a); + session.Save(a2); + session.Save(b); + session.Flush(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = base.OpenSession()) + { + session.Delete("from B"); + session.Delete("from A"); + session.Flush(); + } + } + + [Test] + public void OneToManyPropertyWithFormulaNodeShouldWorkLikeFormulaAttrib() + { + using (ISession session = base.OpenSession()) + { + session.Clear(); + + var b = session.Get<B>(1); + Assert.IsNotNull(b.A2); + Assert.IsNotNull(b.A); + Assert.That(b.A.Id == b.A2.Id); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1834/Mappings.hbm.xml 2009-06-13 21:17:59 UTC (rev 4459) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1834" + default-lazy="false"> + + + + <class name="A"> + <id name="Id" type="Int32"> + <generator class="assigned" /> + </id> + </class> + + <class name="B"> + <id name="Id" type="Int32"> + <generator class="assigned" /> + </id> + + <!--formula attrib should work like formula node--> + <many-to-one name="A" class="A" insert="false" update="false"> + <formula><![CDATA[(select max(A.Id) from A)]]></formula> + </many-to-one> + + <many-to-one name="A2" class="A" insert="false" update="false" formula="(select max(A.Id) from A)"/> + + </class> +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-12 15:34:31 UTC (rev 4458) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-13 21:17:59 UTC (rev 4459) @@ -503,6 +503,8 @@ <Compile Include="NHSpecificTest\NH1813\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1821\Entity.cs" /> <Compile Include="NHSpecificTest\NH1821\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1834\A.cs" /> + <Compile Include="NHSpecificTest\NH1834\Fixture.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1903,6 +1905,7 @@ <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1834\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1821\Mappings.hbm.xml" /> <EmbeddedResource Include="TypeParameters\EntityCustomId.hbm.xml" /> <EmbeddedResource Include="Tools\hbm2ddl\SchemaMetadataUpdaterTest\HeavyEntity.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-14 16:43:57
|
Revision: 4464 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4464&view=rev Author: fabiomaulo Date: 2009-06-14 16:43:55 +0000 (Sun, 14 Jun 2009) Log Message: ----------- - SqlType refactoring - TypeFactory unreported bugs fix - Tests to fix the ugly bugs about SqlType Modified Paths: -------------- trunk/nhibernate/src/NHibernate/SqlTypes/SqlType.cs trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_Defined.hbm.xml trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_Heuristic.hbm.xml trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_InLine.hbm.xml trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_WithColumnNode.hbm.xml trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_WithSqlType.hbm.xml trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeSqlTypeFixture.cs Modified: trunk/nhibernate/src/NHibernate/SqlTypes/SqlType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlTypes/SqlType.cs 2009-06-14 13:09:23 UTC (rev 4463) +++ trunk/nhibernate/src/NHibernate/SqlTypes/SqlType.cs 2009-06-14 16:43:55 UTC (rev 4464) @@ -22,64 +22,61 @@ [Serializable] public class SqlType { - private DbType _dbType; - private int _length; - private byte _precision; - private byte _scale; + private readonly DbType dbType; + private readonly int length; + private readonly byte precision; + private readonly byte scale; + private readonly bool lengthDefined; + private readonly bool precisionDefined; - // false by default - private bool _lengthDefined; - // false by default - private bool _precisionDefined; - public SqlType(DbType dbType) { - _dbType = dbType; + this.dbType = dbType; } public SqlType(DbType dbType, int length) { - _dbType = dbType; - _length = length; - _lengthDefined = true; + this.dbType = dbType; + this.length = length; + lengthDefined = true; } public SqlType(DbType dbType, byte precision, byte scale) { - _dbType = dbType; - _precision = precision; - _scale = scale; - _precisionDefined = true; + this.dbType = dbType; + this.precision = precision; + this.scale = scale; + precisionDefined = true; } public DbType DbType { - get { return _dbType; } + get { return dbType; } } public int Length { - get { return _length; } + get { return length; } } public byte Precision { - get { return _precision; } + get { return precision; } } public byte Scale { - get { return _scale; } + get { return scale; } } public bool LengthDefined { - get { return _lengthDefined; } + get { return lengthDefined; } } public bool PrecisionDefined { - get { return _precisionDefined; } + get { return precisionDefined; } } #region System.Object Members @@ -88,7 +85,7 @@ { unchecked { - int hashCode = 0; + int hashCode; if (LengthDefined) { @@ -109,40 +106,25 @@ public override bool Equals(object obj) { - SqlType rhsSqlType; + return obj == this || Equals(obj as SqlType); + } - // Step1: Perform an equals test - if (obj == this) - { - return true; - } - - // Step 2: Instance of check - rhsSqlType = obj as SqlType; + public bool Equals(SqlType rhsSqlType) + { if (rhsSqlType == null) { return false; } - //Step 3: Check each important field - bool equals = false; if (LengthDefined) { - equals = (DbType.Equals(rhsSqlType.DbType)) - && (Length == rhsSqlType.Length); + return (DbType.Equals(rhsSqlType.DbType)) && (Length == rhsSqlType.Length); } - else if (PrecisionDefined) + if (PrecisionDefined) { - equals = (DbType.Equals(rhsSqlType.DbType)) - && (Precision == rhsSqlType.Precision) - && (Scale == rhsSqlType.Scale); + return (DbType.Equals(rhsSqlType.DbType)) && (Precision == rhsSqlType.Precision) && (Scale == rhsSqlType.Scale); } - else - { - equals = (DbType.Equals(rhsSqlType.DbType)); - } - - return equals; + return (DbType.Equals(rhsSqlType.DbType)); } public override string ToString() @@ -153,7 +135,7 @@ return DbType.ToString(); } - StringBuilder result = new StringBuilder(DbType.ToString()); + var result = new StringBuilder(DbType.ToString()); if (LengthDefined) { Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 13:09:23 UTC (rev 4463) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 16:43:55 UTC (rev 4464) @@ -175,11 +175,16 @@ getTypeDelegatesWithLength.Add(NHibernateUtil.Binary.Name, GetBinaryType); + getTypeDelegatesWithLength.Add(NHibernateUtil.BinaryBlob.Name, GetBinaryType); getTypeDelegatesWithLength.Add(NHibernateUtil.Serializable.Name, GetSerializableType); getTypeDelegatesWithLength.Add(NHibernateUtil.String.Name, GetStringType); + getTypeDelegatesWithLength.Add(NHibernateUtil.StringClob.Name, GetStringType); getTypeDelegatesWithLength.Add(NHibernateUtil.Class.Name, GetTypeType); getTypeDelegatesWithPrecision.Add(NHibernateUtil.Decimal.Name, GetDecimalType); + getTypeDelegatesWithPrecision.Add(NHibernateUtil.Currency.Name, GetDecimalType); + getTypeDelegatesWithPrecision.Add(NHibernateUtil.Double.Name, GetDecimalType); + getTypeDelegatesWithPrecision.Add(NHibernateUtil.Single.Name, GetDecimalType); } public ICollectionTypeFactory CollectionTypeFactory Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-14 13:09:23 UTC (rev 4463) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-14 16:43:55 UTC (rev 4464) @@ -1290,6 +1290,7 @@ <Compile Include="TypesTest\TimestampTypeFixture.cs" /> <Compile Include="TypesTest\TypeFactoryFixture.cs" /> <Compile Include="TypesTest\TypeFixtureBase.cs" /> + <Compile Include="TypesTest\TypeSqlTypeFixture.cs" /> <Compile Include="Unconstrained\Employee.cs" /> <Compile Include="Unconstrained\Person.cs" /> <Compile Include="Unconstrained\SimplyA.cs" /> @@ -1907,6 +1908,11 @@ <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="TypesTest\MultiTypeEntity_WithSqlType.hbm.xml" /> + <EmbeddedResource Include="TypesTest\MultiTypeEntity_WithColumnNode.hbm.xml" /> + <EmbeddedResource Include="TypesTest\MultiTypeEntity_InLine.hbm.xml" /> + <EmbeddedResource Include="TypesTest\MultiTypeEntity_Heuristic.hbm.xml" /> + <EmbeddedResource Include="TypesTest\MultiTypeEntity_Defined.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1835\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1834\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1821\Mappings.hbm.xml" /> Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_Defined.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_Defined.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_Defined.hbm.xml 2009-06-14 16:43:55 UTC (rev 4464) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.TypesTest" + assembly="NHibernate.Test"> + + <class name="MultiTypeEntity"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="StringProp" type="string" length="100" /> + <property name="AnsiStringProp" type="AnsiString" length="101" /> + <property name="Decimal" type="decimal" precision="5" scale="2"/> + <property name="Currency" type="Currency" precision="10" scale="3"/> + <property name="Double" type="Double" precision="11" scale="4"/> + <property name="Float" type="Single" precision="6" scale="3"/> + <property name="BinaryBlob" type="BinaryBlob" length="1000"/> + <property name="Binary" type="Byte[]" length="1001"/> + <property name="StringClob" type="StringClob" length="1002"/> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_Heuristic.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_Heuristic.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_Heuristic.hbm.xml 2009-06-14 16:43:55 UTC (rev 4464) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.TypesTest" + assembly="NHibernate.Test"> + + <class name="MultiTypeEntity"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="StringProp" length="100" /> + <property name="AnsiStringProp" length="101" /> + <property name="Decimal" precision="5" scale="2"/> + <property name="Currency" precision="10" scale="3"/> + <property name="Double" precision="11" scale="4"/> + <property name="Float" precision="6" scale="3"/> + <property name="BinaryBlob" length="1000"/> + <property name="Binary" length="1001"/> + <property name="StringClob" length="1002"/> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_InLine.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_InLine.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_InLine.hbm.xml 2009-06-14 16:43:55 UTC (rev 4464) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.TypesTest" + assembly="NHibernate.Test"> + + <class name="MultiTypeEntity"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="StringProp" type="String(100)"/> + <property name="AnsiStringProp" type="String(101)"/> + <property name="Decimal" type="Decimal(5,2)"/> + <property name="Currency" type="Currency(10,3)"/> + <property name="Double" type="Double(11,4)"/> + <property name="Float" type="Single(6,3)"/> + <property name="BinaryBlob" type="BinaryBlob(1000)"/> + <property name="Binary" type="Byte[](1001)"/> + <property name="StringClob" type="StringClob(1002)"/> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_WithColumnNode.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_WithColumnNode.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_WithColumnNode.hbm.xml 2009-06-14 16:43:55 UTC (rev 4464) @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.TypesTest" + assembly="NHibernate.Test"> + + <class name="MultiTypeEntity"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="StringProp" type="string" > + <column name="StringProp" length="100"/> + </property> + <property name="AnsiStringProp" type="string" > + <column name="AnsiStringProp" length="101"/> + </property> + <property name="Decimal" type="Decimal" > + <column name="Decimal" precision="5" scale="2"/> + </property> + <property name="Currency" type="Currency" > + <column name="Currency" precision="10" scale="3"/> + </property> + <property name="Double" type="Double" > + <column name="Double" precision="11" scale="4"/> + </property> + <property name="Float" type="Single" > + <column name="Float" precision="6" scale="3"/> + </property> + <property name="BinaryBlob" type="BinaryBlob"> + <column name="BinaryBlob" length="1000"/> + </property> + <property name="Binary" type="Byte[]"> + <column name="Binary" length="1001"/> + </property> + <property name="StringClob" type="StringClob"> + <column name="StringClob" length="1002"/> + </property> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_WithSqlType.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_WithSqlType.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/MultiTypeEntity_WithSqlType.hbm.xml 2009-06-14 16:43:55 UTC (rev 4464) @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.TypesTest" + assembly="NHibernate.Test"> + + <class name="MultiTypeEntity"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="StringProp" > + <column name="StringProp" sql-type="varchar(100)"/> + </property> + <property name="AnsiStringProp"> + <column name="AnsiStringProp" sql-type="char(101)"/> + </property> + <property name="Decimal"> + <column name="Decimal" sql-type="decimal(5,2)"/> + </property> + <property name="Currency" > + <column name="Currency" sql-type="decimal(10,3)"/> + </property> + <property name="Double" > + <column name="Double" sql-type="float(11,4)"/> + </property> + <property name="Float" type="Single" > + <column name="Float" sql-type="float(6,3)"/> + </property> + <property name="BinaryBlob" type="BinaryBlob" > + <column name="BinaryBlob" sql-type="varbinary(1000)"/> + </property> + <property name="Binary" type="Byte[]" > + <column name="Binary" sql-type="varbinary(1001)"/> + </property> + <property name="StringClob" type="StringClob"> + <column name="StringClob" sql-type="varchar(1002)"/> + </property> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeSqlTypeFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeSqlTypeFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeSqlTypeFixture.cs 2009-06-14 16:43:55 UTC (rev 4464) @@ -0,0 +1,144 @@ +using NHibernate.Cfg; +using NHibernate.Dialect; +using NHibernate.Engine; +using NUnit.Framework; + +namespace NHibernate.Test.TypesTest +{ + public class MultiTypeEntity + { + public virtual int Id { get; set; } + public virtual string StringProp { get; set; } + public virtual string AnsiStringProp { get; set; } + public virtual decimal Decimal { get; set; } + public virtual decimal Currency { get; set; } + public virtual double Double { get; set; } + public virtual float Float { get; set; } + public virtual byte[] BinaryBlob { get; set; } + public virtual byte[] Binary { get; set; } + public virtual string StringClob { get; set; } + } + + public abstract class TypeSqlTypeFixture + { + protected const string TestNameSpace = "NHibernate.Test.TypesTest."; + protected Configuration cfg; + protected ISessionFactoryImplementor factory; + + [TestFixtureSetUp] + public void Config() + { + cfg = new Configuration(); + if (TestConfigurationHelper.hibernateConfigFile != null) + cfg.Configure(TestConfigurationHelper.hibernateConfigFile); + Dialect.Dialect dialect = Dialect.Dialect.GetDialect(cfg.Properties); + if (!AppliesTo(dialect)) + { + Assert.Ignore(GetType() + " does not apply to " + dialect); + } + + cfg.AddResource(GetResourceFullName(), GetType().Assembly); + + factory = (ISessionFactoryImplementor) cfg.BuildSessionFactory(); + } + + protected virtual bool AppliesTo(Dialect.Dialect dialect) + { + return true; + } + + [Test] + public void NotIgnoreSqlTypeDef() + { + var pc = factory.GetEntityPersister(typeof(MultiTypeEntity).FullName); + + var type = pc.GetPropertyType("StringProp"); + Assert.That(type.SqlTypes(factory)[0].Length, Is.EqualTo(100)); + + type = pc.GetPropertyType("AnsiStringProp"); + Assert.That(type.SqlTypes(factory)[0].Length, Is.EqualTo(101)); + + type = pc.GetPropertyType("Decimal"); + Assert.That(type.SqlTypes(factory)[0].Precision, Is.EqualTo(5)); + Assert.That(type.SqlTypes(factory)[0].Scale, Is.EqualTo(2)); + + type = pc.GetPropertyType("Currency"); + Assert.That(type.SqlTypes(factory)[0].Precision, Is.EqualTo(10)); + Assert.That(type.SqlTypes(factory)[0].Scale, Is.EqualTo(3)); + + type = pc.GetPropertyType("Double"); + Assert.That(type.SqlTypes(factory)[0].Precision, Is.EqualTo(11)); + Assert.That(type.SqlTypes(factory)[0].Scale, Is.EqualTo(4)); + + type = pc.GetPropertyType("Float"); + Assert.That(type.SqlTypes(factory)[0].Precision, Is.EqualTo(6)); + Assert.That(type.SqlTypes(factory)[0].Scale, Is.EqualTo(3)); + + type = pc.GetPropertyType("BinaryBlob"); + Assert.That(type.SqlTypes(factory)[0].Length, Is.EqualTo(1000)); + + type = pc.GetPropertyType("Binary"); + Assert.That(type.SqlTypes(factory)[0].Length, Is.EqualTo(1001)); + + type = pc.GetPropertyType("StringClob"); + Assert.That(type.SqlTypes(factory)[0].Length, Is.EqualTo(1002)); + } + + protected abstract string GetResourceName(); + + private string GetResourceFullName() + { + return TestNameSpace + GetResourceName(); + } + } + + [TestFixture, Ignore("Not fixed yet.")] + public class FixtureWithExplicitDefinedType : TypeSqlTypeFixture + { + protected override string GetResourceName() + { + return "MultiTypeEntity_Defined.hbm.xml"; + } + } + + [TestFixture, Ignore("Not fixed yet.")] + public class FixtureWithHeuristicDefinedType : TypeSqlTypeFixture + { + protected override string GetResourceName() + { + return "MultiTypeEntity_Heuristic.hbm.xml"; + } + } + + [TestFixture] + public class FixtureWithInLineDefinedType : TypeSqlTypeFixture + { + protected override string GetResourceName() + { + return "MultiTypeEntity_InLine.hbm.xml"; + } + } + + [TestFixture, Ignore("Not fixed yet.")] + public class FixtureWithColumnNode : TypeSqlTypeFixture + { + protected override string GetResourceName() + { + return "MultiTypeEntity_WithColumnNode.hbm.xml"; + } + } + + + [TestFixture, Ignore("Not fixed yet.")] + public class FixtureWithSqlType : TypeSqlTypeFixture + { + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect is MsSql2000Dialect; + } + protected override string GetResourceName() + { + return "MultiTypeEntity_WithSqlType.hbm.xml"; + } + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-14 17:35:29
|
Revision: 4465 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4465&view=rev Author: fabiomaulo Date: 2009-06-14 17:35:23 +0000 (Sun, 14 Jun 2009) Log Message: ----------- - Refactoring SqlTypeFactory - Added BinaryBlob to SqlTypeFactory Modified Paths: -------------- trunk/nhibernate/src/NHibernate/SqlTypes/BinaryBlobSqlType.cs trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/SqlTest/SqlTypeFactoryFixture.cs Modified: trunk/nhibernate/src/NHibernate/SqlTypes/BinaryBlobSqlType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlTypes/BinaryBlobSqlType.cs 2009-06-14 16:43:55 UTC (rev 4464) +++ trunk/nhibernate/src/NHibernate/SqlTypes/BinaryBlobSqlType.cs 2009-06-14 17:35:23 UTC (rev 4465) @@ -23,11 +23,7 @@ [Serializable] public class BinaryBlobSqlType : BinarySqlType { - /// <summary> - /// Initializes a new instance of the <see cref="BinaryBlobSqlType"/> class. - /// </summary> - public BinaryBlobSqlType() : base() - { - } + public BinaryBlobSqlType(int length) : base(length) {} + public BinaryBlobSqlType() {} } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-06-14 16:43:55 UTC (rev 4464) +++ trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-06-14 17:35:23 UTC (rev 4465) @@ -52,6 +52,18 @@ return (T) result; } + private static SqlType GetTypeWithPrecision(DbType dbType, byte precision, byte scale) + { + string key = GetKeyForPrecisionScaleBased(dbType.ToString(), precision, scale); + SqlType result; + if (!SqlTypes.TryGetValue(key, out result)) + { + result = new SqlType(dbType, precision, scale); + SqlTypes.Add(key, result); + } + return result; + } + public static AnsiStringSqlType GetAnsiString(int length) { return GetTypeWithLen<AnsiStringSqlType>(length, l => new AnsiStringSqlType(l)); @@ -62,14 +74,19 @@ return GetTypeWithLen<BinarySqlType>(length, l => new BinarySqlType(l)); } + public static BinaryBlobSqlType GetBinaryBlob(int length) + { + return GetTypeWithLen<BinaryBlobSqlType>(length, l => new BinaryBlobSqlType(l)); + } + public static StringSqlType GetString(int length) { return GetTypeWithLen<StringSqlType>(length, l => new StringSqlType(l)); } - public static SqlType GetDecimal(byte precision, byte scale) + public static SqlType GetSqlType(DbType dbType, byte precision, byte scale) { - return new SqlType(DbType.Decimal, precision, scale); + return GetTypeWithPrecision(dbType, precision, scale); } private static string GetKeyForLengthBased(string name, int length) Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 16:43:55 UTC (rev 4464) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 17:35:23 UTC (rev 4465) @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Data; using System.Globalization; using System.Reflection; using NHibernate.Bytecode; @@ -522,7 +523,7 @@ IType returnType; if (!typeByTypeOfName.TryGetValue(key, out returnType)) { - returnType = new DecimalType(SqlTypeFactory.GetDecimal(precision, scale)); + returnType = new DecimalType(SqlTypeFactory.GetSqlType(DbType.Decimal, precision, scale)); AddToTypeOfNameWithPrecision(key, returnType); } Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-14 16:43:55 UTC (rev 4464) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-14 17:35:23 UTC (rev 4465) @@ -1161,6 +1161,7 @@ <Compile Include="SqlTest\Custom\CustomStoredProcSupportTest.cs" /> <Compile Include="SqlTest\Custom\MySQL\MySQLTest.cs" /> <Compile Include="SqlTest\Custom\Oracle\OracleCustomSQLFixture.cs" /> + <Compile Include="SqlTest\SqlTypeFactoryFixture.cs" /> <Compile Include="Stateless\Naturalness.cs" /> <Compile Include="Stateless\StatelessWithRelationsFixture.cs" /> <Compile Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTag.cs" /> Added: trunk/nhibernate/src/NHibernate.Test/SqlTest/SqlTypeFactoryFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/SqlTest/SqlTypeFactoryFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/SqlTest/SqlTypeFactoryFixture.cs 2009-06-14 17:35:23 UTC (rev 4465) @@ -0,0 +1,20 @@ +using System.Data; +using NHibernate.SqlTypes; +using NUnit.Framework; + +namespace NHibernate.Test.SqlTest +{ + [TestFixture] + public class SqlTypeFactoryFixture + { + [Test] + [Description("Should cache constructed types")] + public void GetSqlTypeWithPrecisionScale() + { + var st = SqlTypeFactory.GetSqlType(DbType.Decimal, 10, 2); + Assert.That(st, Is.SameAs(SqlTypeFactory.GetSqlType(DbType.Decimal, 10, 2))); + Assert.That(st, Is.Not.SameAs(SqlTypeFactory.GetSqlType(DbType.Decimal, 10, 1))); + Assert.That(st, Is.Not.SameAs(SqlTypeFactory.GetSqlType(DbType.Double, 10, 2))); + } + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-14 18:25:18
|
Revision: 4467 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4467&view=rev Author: fabiomaulo Date: 2009-06-14 18:25:16 +0000 (Sun, 14 Jun 2009) Log Message: ----------- Fix TypeFactory bugs after tests Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Type/DoubleType.cs trunk/nhibernate/src/NHibernate/Type/SingleType.cs trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs Modified: trunk/nhibernate/src/NHibernate/Type/DoubleType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/DoubleType.cs 2009-06-14 18:17:12 UTC (rev 4466) +++ trunk/nhibernate/src/NHibernate/Type/DoubleType.cs 2009-06-14 18:25:16 UTC (rev 4467) @@ -16,6 +16,8 @@ { } + internal DoubleType(SqlType sqlType) : base(sqlType) {} + /// <summary> /// /// </summary> Modified: trunk/nhibernate/src/NHibernate/Type/SingleType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/SingleType.cs 2009-06-14 18:17:12 UTC (rev 4466) +++ trunk/nhibernate/src/NHibernate/Type/SingleType.cs 2009-06-14 18:25:16 UTC (rev 4467) @@ -20,6 +20,8 @@ { } + internal SingleType(SqlType sqlType) : base(sqlType) {} + /// <summary></summary> public override string Name { Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 18:17:12 UTC (rev 4466) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 18:25:16 UTC (rev 4467) @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; using System.Globalization; using System.Reflection; using NHibernate.Bytecode; @@ -74,6 +73,8 @@ private delegate NullableType GetNullableTypeWithPrecision(byte precision, byte scale); + private delegate NullableType NullableTypeCreatorDelegate(SqlType sqlType); + private static void RegisterType(System.Type systemType, IType nhibernateType, string additionalName) { typeByTypeOfName[systemType.FullName] = nhibernateType; @@ -182,10 +183,14 @@ getTypeDelegatesWithLength.Add(NHibernateUtil.StringClob.Name, GetStringType); getTypeDelegatesWithLength.Add(NHibernateUtil.Class.Name, GetTypeType); - getTypeDelegatesWithPrecision.Add(NHibernateUtil.Decimal.Name, GetDecimalType); - getTypeDelegatesWithPrecision.Add(NHibernateUtil.Currency.Name, GetDecimalType); - getTypeDelegatesWithPrecision.Add(NHibernateUtil.Double.Name, GetDecimalType); - getTypeDelegatesWithPrecision.Add(NHibernateUtil.Single.Name, GetDecimalType); + getTypeDelegatesWithPrecision.Add(NHibernateUtil.Decimal.Name, + (p, s) => GetType(NHibernateUtil.Decimal, p, s, st => new DecimalType(st))); + getTypeDelegatesWithPrecision.Add(NHibernateUtil.Currency.Name, + (p, s) => GetType(NHibernateUtil.Currency, p, s, st => new CurrencyType(st))); + getTypeDelegatesWithPrecision.Add(NHibernateUtil.Double.Name, + (p, s) => GetType(NHibernateUtil.Double, p, s, st => new DoubleType(st))); + getTypeDelegatesWithPrecision.Add(NHibernateUtil.Single.Name, + (p, s) => GetType(NHibernateUtil.Single, p, s, st => new SingleType(st))); } public ICollectionTypeFactory CollectionTypeFactory @@ -516,14 +521,13 @@ return (NullableType)returnType; } - [MethodImpl(MethodImplOptions.Synchronized)] - public static NullableType GetDecimalType(byte precision, byte scale) + private static NullableType GetType(NullableType defaultUnqualifiedType, byte precision, byte scale, NullableTypeCreatorDelegate ctor) { - string key = GetKeyForPrecisionScaleBased(NHibernateUtil.Decimal.Name, precision, scale); + string key = GetKeyForPrecisionScaleBased(defaultUnqualifiedType.Name, precision, scale); IType returnType; if (!typeByTypeOfName.TryGetValue(key, out returnType)) { - returnType = new DecimalType(SqlTypeFactory.GetSqlType(DbType.Decimal, precision, scale)); + returnType = ctor(SqlTypeFactory.GetSqlType(defaultUnqualifiedType.SqlType.DbType, precision, scale)); AddToTypeOfNameWithPrecision(key, returnType); } Modified: trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs 2009-06-14 18:17:12 UTC (rev 4466) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs 2009-06-14 18:25:16 UTC (rev 4467) @@ -111,5 +111,32 @@ log.DebugFormat("{0} calls", totalCall); } + [Test] + public void HoldQualifiedTypes() + { + var decimalType = TypeFactory.Basic("Decimal(10,5)"); + var doubleType = TypeFactory.Basic("Double(10,5)"); + var singleType = TypeFactory.Basic("Single(10,5)"); + var currencyType = TypeFactory.Basic("Currency(10,5)"); + + Assert.That(decimalType, Is.SameAs(TypeFactory.Basic("Decimal(10,5)"))); + Assert.That(decimalType, Is.Not.SameAs(doubleType)); + Assert.That(decimalType, Is.Not.SameAs(singleType)); + Assert.That(decimalType, Is.Not.SameAs(currencyType)); + Assert.That(decimalType, Is.Not.SameAs(TypeFactory.Basic("Decimal(11,5)"))); + + Assert.That(doubleType, Is.SameAs(TypeFactory.Basic("Double(10,5)"))); + Assert.That(doubleType, Is.Not.SameAs(TypeFactory.Basic("Double(11,5)"))); + Assert.That(doubleType, Is.Not.SameAs(singleType)); + Assert.That(doubleType, Is.Not.SameAs(currencyType)); + + Assert.That(singleType, Is.Not.SameAs(currencyType)); + + Assert.That(currencyType, Is.SameAs(TypeFactory.Basic("Currency(10,5)"))); + Assert.That(currencyType, Is.Not.SameAs(TypeFactory.Basic("Currency(11,5)"))); + + Assert.That(singleType, Is.SameAs(TypeFactory.Basic("Single(10,5)"))); + Assert.That(singleType, Is.Not.SameAs(TypeFactory.Basic("Single(11,5)"))); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-14 19:51:45
|
Revision: 4468 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4468&view=rev Author: fabiomaulo Date: 2009-06-14 19:51:40 +0000 (Sun, 14 Jun 2009) Log Message: ----------- Minor Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Mapping/Column.cs trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs Modified: trunk/nhibernate/src/NHibernate/Mapping/Column.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Column.cs 2009-06-14 18:25:16 UTC (rev 4467) +++ trunk/nhibernate/src/NHibernate/Mapping/Column.cs 2009-06-14 19:51:40 UTC (rev 4468) @@ -389,20 +389,20 @@ public SqlType GetSqlTypeCode(IMapping mapping) { - IType _type = Value.Type; + IType type = Value.Type; try { - SqlType _sqlTypeCode = _type.SqlTypes(mapping)[TypeIndex]; - if (SqlTypeCode != null && SqlTypeCode != _sqlTypeCode) + SqlType sqltc = type.SqlTypes(mapping)[TypeIndex]; + if (SqlTypeCode != null && SqlTypeCode != sqltc) { - throw new MappingException(string.Format("SQLType code's does not match. mapped as {0} but is {1}", sqlTypeCode, SqlTypeCode)); + throw new MappingException(string.Format("SQLType code's does not match. mapped as {0} but is {1}", sqltc, SqlTypeCode)); } - return _sqlTypeCode; + return sqltc; } catch (Exception e) { throw new MappingException(string.Format("Could not determine type for column {0} of type {1}: {2}", - name, _type.GetType().FullName, e.GetType().FullName), e); + name, type.GetType().FullName, e.GetType().FullName), e); } } Modified: trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-06-14 18:25:16 UTC (rev 4467) +++ trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-06-14 19:51:40 UTC (rev 4468) @@ -1,6 +1,7 @@ using System; using System.Data; using System.Collections.Generic; +using System.Runtime.CompilerServices; using NHibernate.Util; namespace NHibernate.SqlTypes @@ -84,6 +85,7 @@ return GetTypeWithLen<StringSqlType>(length, l => new StringSqlType(l)); } + [MethodImpl(MethodImplOptions.Synchronized)] public static SqlType GetSqlType(DbType dbType, byte precision, byte scale) { return GetTypeWithPrecision(dbType, precision, scale); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-14 23:29:27
|
Revision: 4471 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4471&view=rev Author: fabiomaulo Date: 2009-06-14 23:28:27 +0000 (Sun, 14 Jun 2009) Log Message: ----------- Fix NH-1835 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Type/BinaryBlobType.cs trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Type/BinaryBlobType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/BinaryBlobType.cs 2009-06-14 21:09:52 UTC (rev 4470) +++ trunk/nhibernate/src/NHibernate/Type/BinaryBlobType.cs 2009-06-14 23:28:27 UTC (rev 4471) @@ -15,6 +15,7 @@ public class BinaryBlobType : BinaryType { internal BinaryBlobType(): base(new BinaryBlobSqlType()) {} + internal BinaryBlobType(BinarySqlType sqlType) : base(sqlType) {} /// <summary></summary> public override string Name Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 21:09:52 UTC (rev 4470) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 23:28:27 UTC (rev 4471) @@ -69,7 +69,7 @@ private static readonly IDictionary<string, GetNullableTypeWithPrecision> getTypeDelegatesWithPrecision = new ThreadSafeDictionary<string, GetNullableTypeWithPrecision>(new Dictionary<string, GetNullableTypeWithPrecision>()); - private delegate NullableType GetNullableTypeWithLength(int length); + private delegate NullableType GetNullableTypeWithLength(int length); // Func<int, NullableType> private delegate NullableType GetNullableTypeWithPrecision(byte precision, byte scale); @@ -176,8 +176,12 @@ typeByTypeOfName["yes_no"] = NHibernateUtil.YesNo; - getTypeDelegatesWithLength.Add(NHibernateUtil.Binary.Name, GetBinaryType); - getTypeDelegatesWithLength.Add(NHibernateUtil.BinaryBlob.Name, GetBinaryType); + getTypeDelegatesWithLength.Add(NHibernateUtil.Binary.Name, + l => + GetType(NHibernateUtil.Binary, l, len => new BinaryType(SqlTypeFactory.GetBinary(len)))); + getTypeDelegatesWithLength.Add(NHibernateUtil.BinaryBlob.Name, + l => + GetType(NHibernateUtil.BinaryBlob, l, len => new BinaryBlobType(SqlTypeFactory.GetBinaryBlob(len)))); getTypeDelegatesWithLength.Add(NHibernateUtil.Serializable.Name, GetSerializableType); getTypeDelegatesWithLength.Add(NHibernateUtil.String.Name, GetStringType); getTypeDelegatesWithLength.Add(NHibernateUtil.StringClob.Name, GetStringType); @@ -520,6 +524,19 @@ return (NullableType)returnType; } + private static NullableType GetType(NullableType defaultUnqualifiedType, int length, GetNullableTypeWithLength ctorDelegate) + { + string key = GetKeyForLengthBased(defaultUnqualifiedType.Name, length); + IType returnType; + if (!typeByTypeOfName.TryGetValue(key, out returnType)) + { + returnType = ctorDelegate(length); + AddToTypeOfNameWithLength(key, returnType); + } + + return (NullableType)returnType; + } + private static NullableType GetType(NullableType defaultUnqualifiedType, byte precision, byte scale, NullableTypeCreatorDelegate ctor) { string key = GetKeyForPrecisionScaleBased(defaultUnqualifiedType.Name, precision, scale); Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs 2009-06-14 21:09:52 UTC (rev 4470) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs 2009-06-14 23:28:27 UTC (rev 4471) @@ -1,16 +1,17 @@ using NUnit.Framework; +using NHibernate.SqlTypes; namespace NHibernate.Test.NHSpecificTest.NH1835 { [TestFixture] public class Fixture: BugTestCase { - [Test, Ignore("Not fixed yet.")] + [Test] public void ColumnTypeBinaryBlob() { var pc = sessions.GetEntityPersister(typeof (Document).FullName); var type = pc.GetPropertyType("Contents"); - Assert.That(type.SqlTypes(sessions)[0].Length, Is.EqualTo(3000)); + Assert.That(type.SqlTypes(sessions)[0], Is.InstanceOf<BinaryBlobSqlType>()); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml 2009-06-14 21:09:52 UTC (rev 4470) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml 2009-06-14 23:28:27 UTC (rev 4471) @@ -7,8 +7,6 @@ <id name="Id"> <generator class="guid.comb" /> </id> - <property name="Contents"> - <column name="Contents" sql-type="varbinary(3000)"/> - </property> + <property name="Contents" type="BinaryBlob(3000)"/> </class> </hibernate-mapping> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-15 03:14:56
|
Revision: 4472 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4472&view=rev Author: fabiomaulo Date: 2009-06-15 03:14:55 +0000 (Mon, 15 Jun 2009) Log Message: ----------- Unreported bug fix Modified Paths: -------------- trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs Modified: trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-06-14 23:28:27 UTC (rev 4471) +++ trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-06-15 03:14:55 UTC (rev 4472) @@ -85,6 +85,11 @@ return GetTypeWithLen<StringSqlType>(length, l => new StringSqlType(l)); } + public static StringClobSqlType GetStringClob(int length) + { + return GetTypeWithLen<StringClobSqlType>(length, l => new StringClobSqlType(l)); + } + [MethodImpl(MethodImplOptions.Synchronized)] public static SqlType GetSqlType(DbType dbType, byte precision, byte scale) { Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 23:28:27 UTC (rev 4471) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-15 03:14:55 UTC (rev 4472) @@ -182,11 +182,24 @@ getTypeDelegatesWithLength.Add(NHibernateUtil.BinaryBlob.Name, l => GetType(NHibernateUtil.BinaryBlob, l, len => new BinaryBlobType(SqlTypeFactory.GetBinaryBlob(len)))); - getTypeDelegatesWithLength.Add(NHibernateUtil.Serializable.Name, GetSerializableType); - getTypeDelegatesWithLength.Add(NHibernateUtil.String.Name, GetStringType); - getTypeDelegatesWithLength.Add(NHibernateUtil.StringClob.Name, GetStringType); - getTypeDelegatesWithLength.Add(NHibernateUtil.Class.Name, GetTypeType); + getTypeDelegatesWithLength.Add(NHibernateUtil.Serializable.Name, + l => + GetType(NHibernateUtil.Serializable, l, + len => new SerializableType(typeof (object), SqlTypeFactory.GetBinary(len)))); + getTypeDelegatesWithLength.Add(NHibernateUtil.String.Name, + l => + GetType(NHibernateUtil.String, l, len => new StringType(SqlTypeFactory.GetString(len)))); + getTypeDelegatesWithLength.Add(NHibernateUtil.StringClob.Name, + l => + GetType(NHibernateUtil.StringClob, l, + len => new StringClobType(SqlTypeFactory.GetStringClob(len)))); + + getTypeDelegatesWithLength.Add(NHibernateUtil.Class.Name, + l => + GetType(NHibernateUtil.Class, l, len => new TypeType(SqlTypeFactory.GetString(len)))); + + getTypeDelegatesWithPrecision.Add(NHibernateUtil.Decimal.Name, (p, s) => GetType(NHibernateUtil.Decimal, p, s, st => new DecimalType(st))); getTypeDelegatesWithPrecision.Add(NHibernateUtil.Currency.Name, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-15 06:50:02
|
Revision: 4479 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4479&view=rev Author: fabiomaulo Date: 2009-06-15 06:49:59 +0000 (Mon, 15 Jun 2009) Log Message: ----------- Fixed the incompatibility of SqlType (now the SqlClientDrive with prepare_sql should work properly) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Mapping/SimpleValue.cs trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeSqlTypeFixture.cs Modified: trunk/nhibernate/src/NHibernate/Mapping/SimpleValue.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/SimpleValue.cs 2009-06-15 06:22:40 UTC (rev 4478) +++ trunk/nhibernate/src/NHibernate/Mapping/SimpleValue.cs 2009-06-15 06:49:59 UTC (rev 4479) @@ -228,7 +228,7 @@ { throw new MappingException("No type name specified"); } - type = TypeFactory.HeuristicType(typeName, typeParameters); + type = GetHeuristicType(); if (type == null) { string msg = "Could not determine type for: " + typeName; @@ -243,6 +243,29 @@ } } + private IType GetHeuristicType() + { + // NH different behavior + // If the mapping has a type as "Double(10,5)" our SqlType will be created with all information + // including the rigth SqlType specification but when the length/presion/scale was specified + // trough attributes the SqlType is wrong (does not include length/presion/scale specification) + + IType result = null; + if (ColumnSpan == 1 && !columns[0].IsFormula) + { + var col = (Column) columns[0]; + if(col.IsLengthDefined()) + { + result = TypeFactory.BuiltInType(typeName, col.Length); + } + else if(col.IsPrecisionDefined()) + { + result = TypeFactory.BuiltInType(typeName, Convert.ToByte(col.Precision), Convert.ToByte(col.Scale)); + } + } + return result ?? TypeFactory.HeuristicType(typeName, typeParameters); + } + public bool HasFormula { get Modified: trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeSqlTypeFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeSqlTypeFixture.cs 2009-06-15 06:22:40 UTC (rev 4478) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TypeSqlTypeFixture.cs 2009-06-15 06:49:59 UTC (rev 4479) @@ -92,7 +92,7 @@ } } - [TestFixture, Ignore("Not fixed yet.")] + [TestFixture] public class FixtureWithExplicitDefinedType : TypeSqlTypeFixture { protected override string GetResourceName() @@ -101,7 +101,7 @@ } } - [TestFixture, Ignore("Not fixed yet.")] + [TestFixture] public class FixtureWithHeuristicDefinedType : TypeSqlTypeFixture { protected override string GetResourceName() @@ -119,7 +119,7 @@ } } - [TestFixture, Ignore("Not fixed yet.")] + [TestFixture] public class FixtureWithColumnNode : TypeSqlTypeFixture { protected override string GetResourceName() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-15 21:59:02
|
Revision: 4481 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4481&view=rev Author: fabiomaulo Date: 2009-06-15 21:59:01 +0000 (Mon, 15 Jun 2009) Log Message: ----------- Prevent fooly usage of prepared queries using MsSQL. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Driver/SqlClientDriver.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/DriverTest/MultiTypeEntity.hbm.xml trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Driver/SqlClientDriver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Driver/SqlClientDriver.cs 2009-06-15 20:50:43 UTC (rev 4480) +++ trunk/nhibernate/src/NHibernate/Driver/SqlClientDriver.cs 2009-06-15 21:59:01 UTC (rev 4481) @@ -93,6 +93,8 @@ private const int MaxStringSize = MaxAnsiStringSize / 2; private const int MaxBinaryBlobSize = int.MaxValue; private const int MaxStringClobSize = MaxBinaryBlobSize / 2; + private const byte MaxPrecision = 28; + private const byte MaxScale = 5; private static void SetDefaultParameterSize(IDbDataParameter dbParam, SqlType sqlType) { @@ -113,7 +115,10 @@ dbParam.Size = MaxBinarySize; } break; - + case DbType.Decimal: + dbParam.Precision = MaxPrecision; + dbParam.Scale = MaxScale; + break; case DbType.String: case DbType.StringFixedLength: if (sqlType is StringClobSqlType) Added: trunk/nhibernate/src/NHibernate.Test/DriverTest/MultiTypeEntity.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/DriverTest/MultiTypeEntity.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/DriverTest/MultiTypeEntity.hbm.xml 2009-06-15 21:59:01 UTC (rev 4481) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.DriverTest" + assembly="NHibernate.Test"> + + <class name="MultiTypeEntity"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="StringProp"/> + <property name="AnsiStringProp" type="AnsiString"/> + <property name="Decimal" type="decimal"/> + <property name="Currency" type="Currency"/> + <property name="Double" column="`Double`" type="Double"/> + <property name="Float" type="Single"/> + <property name="BinaryBlob" type="BinaryBlob"/> + <property name="Binary" type="Byte[]"/> + <property name="StringClob" type="StringClob"/> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs 2009-06-15 21:59:01 UTC (rev 4481) @@ -0,0 +1,85 @@ +using System.Collections; +using NHibernate.Cfg; +using NHibernate.Dialect; +using NUnit.Framework; +using Environment=NHibernate.Cfg.Environment; + +namespace NHibernate.Test.DriverTest +{ + public class MultiTypeEntity + { + public virtual int Id { get; set; } + public virtual string StringProp { get; set; } + public virtual string AnsiStringProp { get; set; } + public virtual decimal Decimal { get; set; } + public virtual decimal Currency { get; set; } + public virtual double Double { get; set; } + public virtual float Float { get; set; } + public virtual byte[] BinaryBlob { get; set; } + public virtual byte[] Binary { get; set; } + public virtual string StringClob { get; set; } + } + + [TestFixture] + public class SqlClientDriverFixture : TestCase + { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.PrepareSql, "true"); + } + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "DriverTest.MultiTypeEntity.hbm.xml" }; } + } + + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect is MsSql2000Dialect; + } + + [Test] + public void Crud() + { + // Should use default dimension for CRUD op and prepare_sql='true' because the mapping does not + // have dimensions specified. + object savedId; + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + savedId = s.Save(new MultiTypeEntity + { + StringProp = "a", StringClob = "a",BinaryBlob = new byte[]{1,2,3}, + Binary = new byte[] { 4, 5, 6 }, Currency = 123.4m, Double = 123.5d, + Decimal = 789.5m + }); + t.Commit(); + } + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + var m = s.Get<MultiTypeEntity>(savedId); + m.StringProp = "b"; + m.StringClob = "b"; + m.BinaryBlob = new byte[] {4,5,6}; + m.Binary = new byte[] {7,8,9}; + m.Currency = 456.78m; + m.Double = 987.6d; + m.Decimal = 1323456.45m; + t.Commit(); + } + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from MultiTypeEntity").ExecuteUpdate(); + t.Commit(); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-15 20:50:43 UTC (rev 4480) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-15 21:59:01 UTC (rev 4481) @@ -147,6 +147,7 @@ <Compile Include="Criteria\MaterialResource.cs" /> <Compile Include="Criteria\ProjectionsTest.cs" /> <Compile Include="Criteria\Reptile.cs" /> + <Compile Include="DriverTest\SqlClientDriverFixture.cs" /> <Compile Include="ExpressionTest\RestrictionsFixture.cs" /> <Compile Include="Criteria\Student.cs" /> <Compile Include="Criteria\StudentDTO.cs" /> @@ -1911,6 +1912,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> + <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1837\Mappings.hbm.xml" /> <EmbeddedResource Include="TypesTest\MultiTypeEntity_WithSqlType.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-16 02:40:38
|
Revision: 4482 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4482&view=rev Author: fabiomaulo Date: 2009-06-16 02:40:36 +0000 (Tue, 16 Jun 2009) Log Message: ----------- Minor refactoring + fix NH-1672 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs Modified: trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-06-15 21:59:01 UTC (rev 4481) +++ trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-06-16 02:40:36 UTC (rev 4482) @@ -33,7 +33,7 @@ public ParameterMetadata GetSQLParameterMetadata(string query) { - ParameterMetadata metadata = (ParameterMetadata)sqlParamMetadataCache[query]; + var metadata = (ParameterMetadata)sqlParamMetadataCache[query]; if (metadata == null) { // for native-sql queries, the param metadata is determined outside @@ -49,8 +49,8 @@ public HQLQueryPlan GetHQLQueryPlan(string queryString, bool shallow, IDictionary<string, IFilter> enabledFilters) { - HQLQueryPlanKey key = new HQLQueryPlanKey(queryString, shallow, enabledFilters); - HQLQueryPlan plan = (HQLQueryPlan)planCache[key]; + var key = new HQLQueryPlanKey(queryString, shallow, enabledFilters); + var plan = (HQLQueryPlan)planCache[key]; if (plan == null) { @@ -59,6 +59,7 @@ log.Debug("unable to locate HQL query plan in cache; generating (" + queryString + ")"); } plan = new HQLQueryPlan(queryString, shallow, enabledFilters, factory); + planCache.Put(key, plan); } else { @@ -68,23 +69,23 @@ } } - planCache.Put(key, plan); - return plan; } public FilterQueryPlan GetFilterQueryPlan(string filterString, string collectionRole, bool shallow, IDictionary<string, IFilter> enabledFilters) { - FilterQueryPlanKey key = new FilterQueryPlanKey(filterString, collectionRole, shallow, enabledFilters); - FilterQueryPlan plan = (FilterQueryPlan)planCache[key]; + var key = new FilterQueryPlanKey(filterString, collectionRole, shallow, enabledFilters); + var plan = (FilterQueryPlan) planCache[key]; if (plan == null) { if (log.IsDebugEnabled) { - log.Debug("unable to locate collection-filter query plan in cache; generating (" + collectionRole + " : " + filterString + ")"); + log.Debug("unable to locate collection-filter query plan in cache; generating (" + collectionRole + " : " + + filterString + ")"); } plan = new FilterQueryPlan(filterString, collectionRole, shallow, enabledFilters, factory); + planCache.Put(key, plan); } else { @@ -94,14 +95,12 @@ } } - planCache.Put(key, plan); - return plan; } public NativeSQLQueryPlan GetNativeSQLQueryPlan(NativeSQLQuerySpecification spec) { - NativeSQLQueryPlan plan = (NativeSQLQueryPlan)planCache[spec]; + var plan = (NativeSQLQueryPlan)planCache[spec]; if (plan == null) { @@ -110,6 +109,7 @@ log.Debug("unable to locate native-sql query plan in cache; generating (" + spec.QueryString + ")"); } plan = new NativeSQLQueryPlan(spec, factory); + planCache.Put(spec, plan); } else { @@ -119,7 +119,6 @@ } } - planCache.Put(spec, plan); return plan; } @@ -127,7 +126,7 @@ { ParamLocationRecognizer recognizer = ParamLocationRecognizer.ParseLocations(sqlString); - OrdinalParameterDescriptor[] ordinalDescriptors = new OrdinalParameterDescriptor[recognizer.OrdinalParameterLocationList.Count]; + var ordinalDescriptors = new OrdinalParameterDescriptor[recognizer.OrdinalParameterLocationList.Count]; for (int i = 0; i < recognizer.OrdinalParameterLocationList.Count; i++) { int position = recognizer.OrdinalParameterLocationList[i]; @@ -177,12 +176,11 @@ public override bool Equals(object obj) { - if (this == obj) - { - return true; - } + return this == obj || Equals(obj as HQLQueryPlanKey); + } - HQLQueryPlanKey that = obj as HQLQueryPlanKey; + public bool Equals(HQLQueryPlanKey that) + { if (that == null) { return false; @@ -245,17 +243,15 @@ public override bool Equals(object obj) { - if (this == obj) + return this == obj || Equals(obj as FilterQueryPlanKey); + } + + public bool Equals(FilterQueryPlanKey that) + { + if (that == null) { - return true; - } - if (obj == null || GetType() != obj.GetType()) - { return false; } - - FilterQueryPlanKey that = (FilterQueryPlanKey)obj; - if (shallow != that.shallow) { return false; Added: trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs 2009-06-16 02:40:36 UTC (rev 4482) @@ -0,0 +1,7 @@ +namespace NHibernate.Test.EngineTest +{ + public class QueryPlanCacheFixture + { + + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-15 21:59:01 UTC (rev 4481) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-16 02:40:36 UTC (rev 4482) @@ -148,6 +148,7 @@ <Compile Include="Criteria\ProjectionsTest.cs" /> <Compile Include="Criteria\Reptile.cs" /> <Compile Include="DriverTest\SqlClientDriverFixture.cs" /> + <Compile Include="EngineTest\QueryPlanCacheFixture.cs" /> <Compile Include="ExpressionTest\RestrictionsFixture.cs" /> <Compile Include="Criteria\Student.cs" /> <Compile Include="Criteria\StudentDTO.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-16 05:19:29
|
Revision: 4484 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4484&view=rev Author: fabiomaulo Date: 2009-06-16 05:19:27 +0000 (Tue, 16 Jun 2009) Log Message: ----------- Fix NH-1069 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs trunk/nhibernate/src/NHibernate/LazyInitializationException.cs trunk/nhibernate/src/NHibernate/Proxy/AbstractLazyInitializer.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/ImproveLazyExceptionFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs 2009-06-16 02:43:15 UTC (rev 4483) +++ trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs 2009-06-16 05:19:27 UTC (rev 4484) @@ -478,7 +478,8 @@ private void ThrowLazyInitializationException(string message) { - throw new LazyInitializationException("failed to lazily initialize a collection" + var ownerEntityName = role == null ? "Unavailable" : StringHelper.Qualifier(role); + throw new LazyInitializationException(ownerEntityName, key, "failed to lazily initialize a collection" + (role == null ? "" : " of role: " + role) + ", " + message); } Modified: trunk/nhibernate/src/NHibernate/LazyInitializationException.cs =================================================================== --- trunk/nhibernate/src/NHibernate/LazyInitializationException.cs 2009-06-16 02:43:15 UTC (rev 4483) +++ trunk/nhibernate/src/NHibernate/LazyInitializationException.cs 2009-06-16 05:19:27 UTC (rev 4484) @@ -14,14 +14,31 @@ /// <summary> /// Initializes a new instance of the <see cref="LazyInitializationException"/> class. /// </summary> + /// <param name="entityName">The name of the entity where the exception was thrown</param> + /// <param name="entityId">The id of the entity where the exception was thrown</param> /// <param name="message">The message that describes the error. </param> - public LazyInitializationException(string message) : this(message, null) + public LazyInitializationException(string entityName, object entityId, string message) + : this(string.Format("Initializing[{0}#{1}]-{2}", entityName, entityId, message)) { + EntityName = entityName; + EntityId = entityId; } + public string EntityName { get; private set; } + public object EntityId { get; private set; } + /// <summary> /// Initializes a new instance of the <see cref="LazyInitializationException"/> class. /// </summary> + /// <param name="message">The message that describes the error. </param> + public LazyInitializationException(string message) + : this(message, null) + { + } + + /// <summary> + /// Initializes a new instance of the <see cref="LazyInitializationException"/> class. + /// </summary> /// <param name="innerException"> /// The exception that is the cause of the current exception. If the innerException parameter /// is not a null reference, the current exception is raised in a catch block that handles Modified: trunk/nhibernate/src/NHibernate/Proxy/AbstractLazyInitializer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Proxy/AbstractLazyInitializer.cs 2009-06-16 02:43:15 UTC (rev 4483) +++ trunk/nhibernate/src/NHibernate/Proxy/AbstractLazyInitializer.cs 2009-06-16 05:19:27 UTC (rev 4484) @@ -55,15 +55,15 @@ { if (_session == null) { - throw new LazyInitializationException("Could not initialize proxy - no Session."); + throw new LazyInitializationException(_entityName, _id, "Could not initialize proxy - no Session."); } else if (!_session.IsOpen) { - throw new LazyInitializationException("Could not initialize proxy - the owning Session was closed."); + throw new LazyInitializationException(_entityName, _id, "Could not initialize proxy - the owning Session was closed."); } else if (!_session.IsConnected) { - throw new LazyInitializationException("Could not initialize proxy - the owning Session is disconnected."); + throw new LazyInitializationException(_entityName, _id, "Could not initialize proxy - the owning Session is disconnected."); } else { @@ -120,7 +120,7 @@ if (value != null && IsConnectedToSession) { //TODO: perhaps this should be some other RuntimeException... - throw new LazyInitializationException("Illegally attempted to associate a proxy with two open Sessions"); + throw new LazyInitializationException(_entityName, _id, "Illegally attempted to associate a proxy with two open Sessions"); } else { Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/Domain.cs 2009-06-16 05:19:27 UTC (rev 4484) @@ -0,0 +1,10 @@ +using Iesi.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1069 +{ + public class LazyE + { + public virtual string Name { get; set; } + public virtual ISet<string> LazyC { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/ImproveLazyExceptionFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/ImproveLazyExceptionFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/ImproveLazyExceptionFixture.cs 2009-06-16 05:19:27 UTC (rev 4484) @@ -0,0 +1,72 @@ +using System; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1069 +{ + [TestFixture] + public class ImproveLazyExceptionFixture: BugTestCase + { + [Test] + public void LazyEntity() + { + object savedId = 1; + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new LazyE(), 1); + t.Commit(); + } + + LazyE le; + using (ISession s = OpenSession()) + { + le = s.Load<LazyE>(savedId); + } + string n; + var ex = Assert.Throws<LazyInitializationException>(() => n= le.Name); + Assert.That(ex.EntityName, Is.EqualTo(typeof (LazyE).FullName)); + Assert.That(ex.EntityId, Is.EqualTo(1)); + Assert.That(ex.Message, Text.Contains(typeof(LazyE).FullName)); + Assert.That(ex.Message, Text.Contains("#1")); + Console.WriteLine(ex.Message); + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from LazyE").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] + public void LazyCollection() + { + object savedId=1; + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new LazyE(), savedId); + t.Commit(); + } + + LazyE le; + using (ISession s = OpenSession()) + { + le = s.Get<LazyE>(savedId); + } + var ex = Assert.Throws<LazyInitializationException>(() => le.LazyC.GetEnumerator()); + Assert.That(ex.EntityName, Is.EqualTo(typeof(LazyE).FullName)); + Assert.That(ex.EntityId, Is.EqualTo(1)); + Assert.That(ex.Message, Text.Contains(typeof(LazyE).FullName)); + Assert.That(ex.Message, Text.Contains("#1")); + Assert.That(ex.Message, Text.Contains(typeof(LazyE).FullName + ".LazyC")); + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from LazyE").ExecuteUpdate(); + t.Commit(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1069/Mappings.hbm.xml 2009-06-16 05:19:27 UTC (rev 4484) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1069" + assembly="NHibernate.Test"> + <class name="LazyE"> + <id type="int"/> + <property name="Name"/> + <set name="LazyC"> + <key column="leid"/> + <element column="LValue"/> + </set> + </class> +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-16 02:43:15 UTC (rev 4483) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-16 05:19:27 UTC (rev 4484) @@ -356,6 +356,8 @@ <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> <Compile Include="NHSpecificTest\NH1044\Domain.cs" /> <Compile Include="NHSpecificTest\NH1044\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1069\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1069\ImproveLazyExceptionFixture.cs" /> <Compile Include="NHSpecificTest\NH1092\Domain.cs" /> <Compile Include="NHSpecificTest\NH1092\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1093\Fixture.cs" /> @@ -1914,6 +1916,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1069\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1837\Mappings.hbm.xml" /> <EmbeddedResource Include="TypesTest\MultiTypeEntity_WithSqlType.hbm.xml" /> <EmbeddedResource Include="TypesTest\MultiTypeEntity_WithColumnNode.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-16 14:25:55
|
Revision: 4486 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4486&view=rev Author: fabiomaulo Date: 2009-06-16 14:25:52 +0000 (Tue, 16 Jun 2009) Log Message: ----------- Minor refactoring Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Action/BulkOperationCleanupAction.cs trunk/nhibernate/src/NHibernate/Action/CollectionAction.cs trunk/nhibernate/src/NHibernate/Action/EntityAction.cs trunk/nhibernate/src/NHibernate/Action/IExecutable.cs trunk/nhibernate/src/NHibernate/Engine/ActionQueue.cs Modified: trunk/nhibernate/src/NHibernate/Action/BulkOperationCleanupAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/BulkOperationCleanupAction.cs 2009-06-16 05:35:24 UTC (rev 4485) +++ trunk/nhibernate/src/NHibernate/Action/BulkOperationCleanupAction.cs 2009-06-16 14:25:52 UTC (rev 4486) @@ -97,7 +97,7 @@ #region IExecutable Members - public object[] PropertySpaces + public string[] PropertySpaces { get { return spaces.ToArray(); } } Modified: trunk/nhibernate/src/NHibernate/Action/CollectionAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/CollectionAction.cs 2009-06-16 05:35:24 UTC (rev 4485) +++ trunk/nhibernate/src/NHibernate/Action/CollectionAction.cs 2009-06-16 14:25:52 UTC (rev 4486) @@ -79,7 +79,7 @@ /// <summary> /// What spaces (tables) are affected by this action? /// </summary> - public object[] PropertySpaces + public string[] PropertySpaces { get { return Persister.CollectionSpaces; } } Modified: trunk/nhibernate/src/NHibernate/Action/EntityAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityAction.cs 2009-06-16 05:35:24 UTC (rev 4485) +++ trunk/nhibernate/src/NHibernate/Action/EntityAction.cs 2009-06-16 14:25:52 UTC (rev 4486) @@ -90,7 +90,7 @@ #region IExecutable Members - public object[] PropertySpaces + public string[] PropertySpaces { get { return persister.PropertySpaces; } } Modified: trunk/nhibernate/src/NHibernate/Action/IExecutable.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/IExecutable.cs 2009-06-16 05:35:24 UTC (rev 4485) +++ trunk/nhibernate/src/NHibernate/Action/IExecutable.cs 2009-06-16 14:25:52 UTC (rev 4486) @@ -10,7 +10,7 @@ /// <summary> /// What spaces (tables) are affected by this action? /// </summary> - object[] PropertySpaces { get;} + string[] PropertySpaces { get;} /// <summary> Called before executing any actions</summary> void BeforeExecutions(); Modified: trunk/nhibernate/src/NHibernate/Engine/ActionQueue.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ActionQueue.cs 2009-06-16 05:35:24 UTC (rev 4485) +++ trunk/nhibernate/src/NHibernate/Engine/ActionQueue.cs 2009-06-16 14:25:52 UTC (rev 4486) @@ -228,11 +228,11 @@ get { return (insertions.Count > 0 || deletions.Count > 0); } } - private static bool AreTablesToUpdated(IList executables, ISet<string> tablespaces) + private static bool AreTablesToUpdated(IList executables, ICollection<string> tablespaces) { foreach (IExecutable exec in executables) { - object[] spaces = exec.PropertySpaces; + var spaces = exec.PropertySpaces; foreach (string o in spaces) { if(tablespaces.Contains(o)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-19 15:50:15
|
Revision: 4490 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4490&view=rev Author: fabiomaulo Date: 2009-06-19 15:50:13 +0000 (Fri, 19 Jun 2009) Log Message: ----------- Improve of MsSql2000Dialect overriding available Dialect configuration. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs trunk/nhibernate/src/NHibernate.Test/DialectTest/DialectFixture.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-06-18 22:32:11 UTC (rev 4489) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-06-19 15:50:13 UTC (rev 4490) @@ -146,6 +146,26 @@ get { return " null"; } } + public override string CurrentTimestampSQLFunctionName + { + get { return "CURRENT_TIMESTAMP"; } + } + + public override string CurrentTimestampSelectString + { + get { return "SELECT CURRENT_TIMESTAMP"; } + } + + public override bool IsCurrentTimestampSelectStringCallable + { + get { return false; } + } + + public override bool SupportsCurrentTimestampSelection + { + get { return true; } + } + /// <summary></summary> public override bool QualifyIndexName { Modified: trunk/nhibernate/src/NHibernate.Test/DialectTest/DialectFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/DialectTest/DialectFixture.cs 2009-06-18 22:32:11 UTC (rev 4489) +++ trunk/nhibernate/src/NHibernate.Test/DialectTest/DialectFixture.cs 2009-06-19 15:50:13 UTC (rev 4490) @@ -1,7 +1,13 @@ +using System; using System.Collections.Generic; -using NHibernate.Cfg; +using System.Data; using NHibernate.Dialect; +using NHibernate.Driver; +using NHibernate.Engine; +using NHibernate.SqlCommand; +using NHibernate.SqlTypes; using NUnit.Framework; +using Environment=NHibernate.Cfg.Environment; namespace NHibernate.Test.DialectTest { @@ -132,5 +138,31 @@ Dialect.Dialect dialect = Dialect.Dialect.GetDialect(props); Assert.IsTrue(dialect is MsSql2000Dialect); } + + [Test] + public void CurrentTimestampSelection() + { + var conf = TestConfigurationHelper.GetDefaultConfiguration(); + Dialect.Dialect dialect = Dialect.Dialect.GetDialect(conf.Properties); + if (!dialect.SupportsCurrentTimestampSelection) + { + Assert.Ignore("This test does not apply to " + dialect.GetType().FullName); + } + var sessions = (ISessionFactoryImplementor) conf.BuildSessionFactory(); + sessions.ConnectionProvider.Configure(conf.Properties); + IDriver driver = sessions.ConnectionProvider.Driver; + + using (IDbConnection connection = sessions.ConnectionProvider.GetConnection()) + { + IDbCommand statement = driver.GenerateCommand(CommandType.Text, new SqlString(dialect.CurrentTimestampSelectString), + new SqlType[0]); + statement.Connection = connection; + using(IDataReader reader = statement.ExecuteReader()) + { + Assert.That(reader.Read(), "should return one record"); + Assert.That(reader[0], Is.InstanceOf<DateTime>()); + } + } + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-06-20 02:50:22
|
Revision: 4491 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4491&view=rev Author: steverstrong Date: 2009-06-20 00:23:15 +0000 (Sat, 20 Jun 2009) Log Message: ----------- Fixes for a couple of ANTLR parser bugs, specifically NH-1831 and SqlTranslationFixture tests Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlParser.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/SqlGenerator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.g trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SqlTranslationFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Entities.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs 2009-06-19 15:50:13 UTC (rev 4490) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs 2009-06-20 00:23:15 UTC (rev 4491) @@ -1,4719 +1,4719 @@ -// $ANTLR 3.1.2 C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g 2009-06-18 19:12:17 - -// The variable 'variable' is assigned but its value is never used. -#pragma warning disable 168, 219 -// Unreachable code detected. -#pragma warning disable 162 -namespace NHibernate.Hql.Ast.ANTLR -{ - -using System; -using Antlr.Runtime; -using IList = System.Collections.IList; -using ArrayList = System.Collections.ArrayList; -using Stack = Antlr.Runtime.Collections.StackList; - -using IDictionary = System.Collections.IDictionary; -using Hashtable = System.Collections.Hashtable; - -public partial class HqlLexer : Lexer { - public const int LT = 108; - public const int EXPONENT = 127; - public const int STAR = 115; - public const int FLOAT_SUFFIX = 128; - public const int LITERAL_by = 54; - public const int CASE = 55; - public const int NEW = 37; - public const int FILTER_ENTITY = 74; - public const int PARAM = 120; - public const int COUNT = 12; - public const int NOT = 38; - public const int EOF = -1; - public const int UNARY_PLUS = 89; - public const int QUOTED_String = 121; - public const int ESCqs = 125; - public const int WEIRD_IDENT = 91; - public const int OPEN_BRACKET = 117; - public const int FULL = 23; - public const int ORDER_ELEMENT = 83; - public const int IS_NULL = 78; - public const int ESCAPE = 18; - public const int INSERT = 29; - public const int BOTH = 62; - public const int VERSIONED = 52; - public const int EQ = 99; - public const int SELECT = 45; - public const int INTO = 30; - public const int NE = 106; - public const int GE = 111; - public const int CONCAT = 112; - public const int ID_LETTER = 124; - public const int NULL = 39; - public const int ELSE = 57; - public const int SELECT_FROM = 87; - public const int TRAILING = 68; - public const int ON = 60; - public const int NUM_LONG = 96; - public const int NUM_DOUBLE = 94; - public const int UNARY_MINUS = 88; - public const int DELETE = 13; - public const int INDICES = 27; - public const int OF = 67; - public const int METHOD_CALL = 79; - public const int LEADING = 64; - public const int EMPTY = 63; - public const int GROUP = 24; - public const int WS = 126; - public const int FETCH = 21; - public const int VECTOR_EXPR = 90; - public const int NOT_IN = 81; - public const int NUM_INT = 93; - public const int OR = 40; - public const int ALIAS = 70; - public const int JAVA_CONSTANT = 97; - public const int CONSTANT = 92; - public const int GT = 109; - public const int QUERY = 84; - public const int BNOT = 102; - public const int INDEX_OP = 76; - public const int NUM_FLOAT = 95; - public const int FROM = 22; - public const int END = 56; - public const int FALSE = 20; - public const int T__130 = 130; - public const int DISTINCT = 16; - public const int T__131 = 131; - public const int CONSTRUCTOR = 71; - public const int CLOSE_BRACKET = 118; - public const int WHERE = 53; - public const int CLASS = 11; - public const int MEMBER = 65; - public const int INNER = 28; - public const int PROPERTIES = 43; - public const int ORDER = 41; - public const int MAX = 35; - public const int UPDATE = 51; - public const int SQL_NE = 107; - public const int AND = 6; - public const int SUM = 48; - public const int ASCENDING = 8; - public const int EXPR_LIST = 73; - public const int AS = 7; - public const int IN = 26; - public const int THEN = 58; - public const int OBJECT = 66; - public const int COMMA = 98; - public const int IS = 31; - public const int LEFT = 33; - public const int AVG = 9; - public const int SOME = 47; - public const int ALL = 4; - public const int BOR = 103; - public const int IDENT = 122; - public const int CASE2 = 72; - public const int BXOR = 104; - public const int PLUS = 113; - public const int EXISTS = 19; - public const int DOT = 15; - public const int WITH = 61; - public const int LIKE = 34; - public const int OUTER = 42; - public const int ID_START_LETTER = 123; - public const int ROW_STAR = 86; - public const int NOT_LIKE = 82; - public const int RANGE = 85; - public const int NOT_BETWEEN = 80; - public const int HEX_DIGIT = 129; - public const int SET = 46; - public const int RIGHT = 44; - public const int HAVING = 25; - public const int MIN = 36; - public const int IS_NOT_NULL = 77; - public const int MINUS = 114; - public const int ELEMENTS = 17; - public const int BAND = 105; - public const int TRUE = 49; - public const int JOIN = 32; - public const int IN_LIST = 75; - public const int UNION = 50; - public const int OPEN = 100; - public const int COLON = 119; - public const int ANY = 5; - public const int CLOSE = 101; - public const int WHEN = 59; - public const int DIV = 116; - public const int DESCENDING = 14; - public const int AGGREGATE = 69; - public const int BETWEEN = 10; - public const int LE = 110; - - // delegates - // delegators - - public HqlLexer() - { - InitializeCyclicDFAs(); - } - public HqlLexer(ICharStream input) - : this(input, null) { - } - public HqlLexer(ICharStream input, RecognizerSharedState state) - : base(input, state) { - InitializeCyclicDFAs(); - - } - - override public string GrammarFileName - { - get { return "C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g";} - } - - // $ANTLR start "ALL" - public void mALL() // throws RecognitionException [2] - { - try - { - int _type = ALL; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:9:5: ( 'all' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:9:7: 'all' - { - Match("all"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ALL" - - // $ANTLR start "ANY" - public void mANY() // throws RecognitionException [2] - { - try - { - int _type = ANY; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:10:5: ( 'any' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:10:7: 'any' - { - Match("any"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ANY" - - // $ANTLR start "AND" - public void mAND() // throws RecognitionException [2] - { - try - { - int _type = AND; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:11:5: ( 'and' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:11:7: 'and' - { - Match("and"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "AND" - - // $ANTLR start "AS" - public void mAS() // throws RecognitionException [2] - { - try - { - int _type = AS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:12:4: ( 'as' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:12:6: 'as' - { - Match("as"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "AS" - - // $ANTLR start "ASCENDING" - public void mASCENDING() // throws RecognitionException [2] - { - try - { - int _type = ASCENDING; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:13:11: ( 'asc' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:13:13: 'asc' - { - Match("asc"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ASCENDING" - - // $ANTLR start "AVG" - public void mAVG() // throws RecognitionException [2] - { - try - { - int _type = AVG; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:14:5: ( 'avg' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:14:7: 'avg' - { - Match("avg"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "AVG" - - // $ANTLR start "BETWEEN" - public void mBETWEEN() // throws RecognitionException [2] - { - try - { - int _type = BETWEEN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:15:9: ( 'between' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:15:11: 'between' - { - Match("between"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "BETWEEN" - - // $ANTLR start "CLASS" - public void mCLASS() // throws RecognitionException [2] - { - try - { - int _type = CLASS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:16:7: ( 'class' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:16:9: 'class' - { - Match("class"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "CLASS" - - // $ANTLR start "COUNT" - public void mCOUNT() // throws RecognitionException [2] - { - try - { - int _type = COUNT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:17:7: ( 'count' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:17:9: 'count' - { - Match("count"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "COUNT" - - // $ANTLR start "DELETE" - public void mDELETE() // throws RecognitionException [2] - { - try - { - int _type = DELETE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:18:8: ( 'delete' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:18:10: 'delete' - { - Match("delete"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "DELETE" - - // $ANTLR start "DESCENDING" - public void mDESCENDING() // throws RecognitionException [2] - { - try - { - int _type = DESCENDING; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:19:12: ( 'desc' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:19:14: 'desc' - { - Match("desc"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "DESCENDING" - - // $ANTLR start "DISTINCT" - public void mDISTINCT() // throws RecognitionException [2] - { - try - { - int _type = DISTINCT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:20:10: ( 'distinct' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:20:12: 'distinct' - { - Match("distinct"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "DISTINCT" - - // $ANTLR start "ELEMENTS" - public void mELEMENTS() // throws RecognitionException [2] - { - try - { - int _type = ELEMENTS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:21:10: ( 'elements' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:21:12: 'elements' - { - Match("elements"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ELEMENTS" - - // $ANTLR start "ESCAPE" - public void mESCAPE() // throws RecognitionException [2] - { - try - { - int _type = ESCAPE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:22:8: ( 'escape' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:22:10: 'escape' - { - Match("escape"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ESCAPE" - - // $ANTLR start "EXISTS" - public void mEXISTS() // throws RecognitionException [2] - { - try - { - int _type = EXISTS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:23:8: ( 'exists' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:23:10: 'exists' - { - Match("exists"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "EXISTS" - - // $ANTLR start "FALSE" - public void mFALSE() // throws RecognitionException [2] - { - try - { - int _type = FALSE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:24:7: ( 'false' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:24:9: 'false' - { - Match("false"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "FALSE" - - // $ANTLR start "FETCH" - public void mFETCH() // throws RecognitionException [2] - { - try - { - int _type = FETCH; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:25:7: ( 'fetch' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:25:9: 'fetch' - { - Match("fetch"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "FETCH" - - // $ANTLR start "FROM" - public void mFROM() // throws RecognitionException [2] - { - try - { - int _type = FROM; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:26:6: ( 'from' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:26:8: 'from' - { - Match("from"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "FROM" - - // $ANTLR start "FULL" - public void mFULL() // throws RecognitionException [2] - { - try - { - int _type = FULL; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:27:6: ( 'full' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:27:8: 'full' - { - Match("full"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "FULL" - - // $ANTLR start "GROUP" - public void mGROUP() // throws RecognitionException [2] - { - try - { - int _type = GROUP; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:28:7: ( 'group' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:28:9: 'group' - { - Match("group"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "GROUP" - - // $ANTLR start "HAVING" - public void mHAVING() // throws RecognitionException [2] - { - try - { - int _type = HAVING; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:29:8: ( 'having' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:29:10: 'having' - { - Match("having"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "HAVING" - - // $ANTLR start "IN" - public void mIN() // throws RecognitionException [2] - { - try - { - int _type = IN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:30:4: ( 'in' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:30:6: 'in' - { - Match("in"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "IN" - - // $ANTLR start "INDICES" - public void mINDICES() // throws RecognitionException [2] - { - try - { - int _type = INDICES; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:31:9: ( 'indices' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:31:11: 'indices' - { - Match("indices"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "INDICES" - - // $ANTLR start "INNER" - public void mINNER() // throws RecognitionException [2] - { - try - { - int _type = INNER; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:32:7: ( 'inner' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:32:9: 'inner' - { - Match("inner"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "INNER" - - // $ANTLR start "INSERT" - public void mINSERT() // throws RecognitionException [2] - { - try - { - int _type = INSERT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:33:8: ( 'insert' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:33:10: 'insert' - { - Match("insert"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "INSERT" - - // $ANTLR start "INTO" - public void mINTO() // throws RecognitionException [2] - { - try - { - int _type = INTO; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:34:6: ( 'into' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:34:8: 'into' - { - Match("into"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "INTO" - - // $ANTLR start "IS" - public void mIS() // throws RecognitionException [2] - { - try - { - int _type = IS; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:35:4: ( 'is' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:35:6: 'is' - { - Match("is"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "IS" - - // $ANTLR start "JOIN" - public void mJOIN() // throws RecognitionException [2] - { - try - { - int _type = JOIN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:36:6: ( 'join' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:36:8: 'join' - { - Match("join"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "JOIN" - - // $ANTLR start "LEFT" - public void mLEFT() // throws RecognitionException [2] - { - try - { - int _type = LEFT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:37:6: ( 'left' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:37:8: 'left' - { - Match("left"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LEFT" - - // $ANTLR start "LIKE" - public void mLIKE() // throws RecognitionException [2] - { - try - { - int _type = LIKE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:38:6: ( 'like' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:38:8: 'like' - { - Match("like"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LIKE" - - // $ANTLR start "MAX" - public void mMAX() // throws RecognitionException [2] - { - try - { - int _type = MAX; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:39:5: ( 'max' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:39:7: 'max' - { - Match("max"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "MAX" - - // $ANTLR start "MIN" - public void mMIN() // throws RecognitionException [2] - { - try - { - int _type = MIN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:40:5: ( 'min' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:40:7: 'min' - { - Match("min"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "MIN" - - // $ANTLR start "NEW" - public void mNEW() // throws RecognitionException [2] - { - try - { - int _type = NEW; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:41:5: ( 'new' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:41:7: 'new' - { - Match("new"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "NEW" - - // $ANTLR start "NOT" - public void mNOT() // throws RecognitionException [2] - { - try - { - int _type = NOT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:42:5: ( 'not' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:42:7: 'not' - { - Match("not"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "NOT" - - // $ANTLR start "NULL" - public void mNULL() // throws RecognitionException [2] - { - try - { - int _type = NULL; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:43:6: ( 'null' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:43:8: 'null' - { - Match("null"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "NULL" - - // $ANTLR start "OR" - public void mOR() // throws RecognitionException [2] - { - try - { - int _type = OR; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:44:4: ( 'or' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:44:6: 'or' - { - Match("or"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OR" - - // $ANTLR start "ORDER" - public void mORDER() // throws RecognitionException [2] - { - try - { - int _type = ORDER; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:45:7: ( 'order' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:45:9: 'order' - { - Match("order"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ORDER" - - // $ANTLR start "OUTER" - public void mOUTER() // throws RecognitionException [2] - { - try - { - int _type = OUTER; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:46:7: ( 'outer' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:46:9: 'outer' - { - Match("outer"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OUTER" - - // $ANTLR start "PROPERTIES" - public void mPROPERTIES() // throws RecognitionException [2] - { - try - { - int _type = PROPERTIES; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:47:12: ( 'properties' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:47:14: 'properties' - { - Match("properties"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "PROPERTIES" - - // $ANTLR start "RIGHT" - public void mRIGHT() // throws RecognitionException [2] - { - try - { - int _type = RIGHT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:48:7: ( 'right' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:48:9: 'right' - { - Match("right"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "RIGHT" - - // $ANTLR start "SELECT" - public void mSELECT() // throws RecognitionException [2] - { - try - { - int _type = SELECT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:49:8: ( 'select' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:49:10: 'select' - { - Match("select"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "SELECT" - - // $ANTLR start "SET" - public void mSET() // throws RecognitionException [2] - { - try - { - int _type = SET; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:50:5: ( 'set' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:50:7: 'set' - { - Match("set"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "SET" - - // $ANTLR start "SOME" - public void mSOME() // throws RecognitionException [2] - { - try - { - int _type = SOME; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:51:6: ( 'some' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:51:8: 'some' - { - Match("some"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "SOME" - - // $ANTLR start "SUM" - public void mSUM() // throws RecognitionException [2] - { - try - { - int _type = SUM; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:52:5: ( 'sum' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:52:7: 'sum' - { - Match("sum"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "SUM" - - // $ANTLR start "TRUE" - public void mTRUE() // throws RecognitionException [2] - { - try - { - int _type = TRUE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:53:6: ( 'true' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:53:8: 'true' - { - Match("true"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "TRUE" - - // $ANTLR start "UNION" - public void mUNION() // throws RecognitionException [2] - { - try - { - int _type = UNION; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:54:7: ( 'union' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:54:9: 'union' - { - Match("union"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "UNION" - - // $ANTLR start "UPDATE" - public void mUPDATE() // throws RecognitionException [2] - { - try - { - int _type = UPDATE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:55:8: ( 'update' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:55:10: 'update' - { - Match("update"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "UPDATE" - - // $ANTLR start "VERSIONED" - public void mVERSIONED() // throws RecognitionException [2] - { - try - { - int _type = VERSIONED; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:56:11: ( 'versioned' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:56:13: 'versioned' - { - Match("versioned"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "VERSIONED" - - // $ANTLR start "WHERE" - public void mWHERE() // throws RecognitionException [2] - { - try - { - int _type = WHERE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:57:7: ( 'where' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:57:9: 'where' - { - Match("where"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "WHERE" - - // $ANTLR start "LITERAL_by" - public void mLITERAL_by() // throws RecognitionException [2] - { - try - { - int _type = LITERAL_by; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:58:12: ( 'by' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:58:14: 'by' - { - Match("by"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LITERAL_by" - - // $ANTLR start "CASE" - public void mCASE() // throws RecognitionException [2] - { - try - { - int _type = CASE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:59:6: ( 'case' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:59:8: 'case' - { - Match("case"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "CASE" - - // $ANTLR start "END" - public void mEND() // throws RecognitionException [2] - { - try - { - int _type = END; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:60:5: ( 'end' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:60:7: 'end' - { - Match("end"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "END" - - // $ANTLR start "ELSE" - public void mELSE() // throws RecognitionException [2] - { - try - { - int _type = ELSE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:61:6: ( 'else' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:61:8: 'else' - { - Match("else"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ELSE" - - // $ANTLR start "THEN" - public void mTHEN() // throws RecognitionException [2] - { - try - { - int _type = THEN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:62:6: ( 'then' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:62:8: 'then' - { - Match("then"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "THEN" - - // $ANTLR start "WHEN" - public void mWHEN() // throws RecognitionException [2] - { - try - { - int _type = WHEN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:63:6: ( 'when' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:63:8: 'when' - { - Match("when"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "WHEN" - - // $ANTLR start "ON" - public void mON() // throws RecognitionException [2] - { - try - { - int _type = ON; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:64:4: ( 'on' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:64:6: 'on' - { - Match("on"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "ON" - - // $ANTLR start "WITH" - public void mWITH() // throws RecognitionException [2] - { - try - { - int _type = WITH; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:65:6: ( 'with' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:65:8: 'with' - { - Match("with"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "WITH" - - // $ANTLR start "BOTH" - public void mBOTH() // throws RecognitionException [2] - { - try - { - int _type = BOTH; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:66:6: ( 'both' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:66:8: 'both' - { - Match("both"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "BOTH" - - // $ANTLR start "EMPTY" - public void mEMPTY() // throws RecognitionException [2] - { - try - { - int _type = EMPTY; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:67:7: ( 'empty' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:67:9: 'empty' - { - Match("empty"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "EMPTY" - - // $ANTLR start "LEADING" - public void mLEADING() // throws RecognitionException [2] - { - try - { - int _type = LEADING; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:68:9: ( 'leading' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:68:11: 'leading' - { - Match("leading"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LEADING" - - // $ANTLR start "MEMBER" - public void mMEMBER() // throws RecognitionException [2] - { - try - { - int _type = MEMBER; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:69:8: ( 'member' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:69:10: 'member' - { - Match("member"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "MEMBER" - - // $ANTLR start "OBJECT" - public void mOBJECT() // throws RecognitionException [2] - { - try - { - int _type = OBJECT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:70:8: ( 'object' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:70:10: 'object' - { - Match("object"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OBJECT" - - // $ANTLR start "OF" - public void mOF() // throws RecognitionException [2] - { - try - { - int _type = OF; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:71:4: ( 'of' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:71:6: 'of' - { - Match("of"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OF" - - // $ANTLR start "TRAILING" - public void mTRAILING() // throws RecognitionException [2] - { - try - { - int _type = TRAILING; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:72:10: ( 'trailing' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:72:12: 'trailing' - { - Match("trailing"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "TRAILING" - - // $ANTLR start "T__130" - public void mT__130() // throws RecognitionException [2] - { - try - { - int _type = T__130; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:73:8: ( 'ascending' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:73:10: 'ascending' - { - Match("ascending"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "T__130" - - // $ANTLR start "T__131" - public void mT__131() // throws RecognitionException [2] - { - try - { - int _type = T__131; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:74:8: ( 'descending' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:74:10: 'descending' - { - Match("descending"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "T__131" - - // $ANTLR start "EQ" - public void mEQ() // throws RecognitionException [2] - { - try - { - int _type = EQ; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:758:3: ( '=' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:758:5: '=' - { - Match('='); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "EQ" - - // $ANTLR start "LT" - public void mLT() // throws RecognitionException [2] - { - try - { - int _type = LT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:759:3: ( '<' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:759:5: '<' - { - Match('<'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LT" - - // $ANTLR start "GT" - public void mGT() // throws RecognitionException [2] - { - try - { - int _type = GT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:760:3: ( '>' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:760:5: '>' - { - Match('>'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "GT" - - // $ANTLR start "SQL_NE" - public void mSQL_NE() // throws RecognitionException [2] - { - try - { - int _type = SQL_NE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:761:7: ( '<>' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:761:9: '<>' - { - Match("<>"); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "SQL_NE" - - // $ANTLR start "NE" - public void mNE() // throws RecognitionException [2] - { - try - { - int _type = NE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:762:3: ( '!=' | '^=' ) - int alt1 = 2; - int LA1_0 = input.LA(1); - - if ( (LA1_0 == '!') ) - { - alt1 = 1; - } - else if ( (LA1_0 == '^') ) - { - alt1 = 2; - } - else - { - if ( state.backtracking > 0 ) {state.failed = true; return ;} - NoViableAltException nvae_d1s0 = - new NoViableAltException("", 1, 0, input); - - throw nvae_d1s0; - } - switch (alt1) - { - case 1 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:762:5: '!=' - { - Match("!="); if (state.failed) return ; - - - } - break; - case 2 : - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:762:12: '^=' - { - Match("^="); if (state.failed) return ; - - - } - break; - - } - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "NE" - - // $ANTLR start "LE" - public void mLE() // throws RecognitionException [2] - { - try - { - int _type = LE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:763:3: ( '<=' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:763:5: '<=' - { - Match("<="); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "LE" - - // $ANTLR start "GE" - public void mGE() // throws RecognitionException [2] - { - try - { - int _type = GE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:764:3: ( '>=' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:764:5: '>=' - { - Match(">="); if (state.failed) return ; - - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "GE" - - // $ANTLR start "BOR" - public void mBOR() // throws RecognitionException [2] - { - try - { - int _type = BOR; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:766:5: ( '|' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:766:8: '|' - { - Match('|'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "BOR" - - // $ANTLR start "BXOR" - public void mBXOR() // throws RecognitionException [2] - { - try - { - int _type = BXOR; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:767:6: ( '^' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:767:8: '^' - { - Match('^'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "BXOR" - - // $ANTLR start "BAND" - public void mBAND() // throws RecognitionException [2] - { - try - { - int _type = BAND; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:768:6: ( '&' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:768:8: '&' - { - Match('&'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "BAND" - - // $ANTLR start "BNOT" - public void mBNOT() // throws RecognitionException [2] - { - try - { - int _type = BNOT; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:769:6: ( '!' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:769:8: '!' - { - Match('!'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "BNOT" - - // $ANTLR start "COMMA" - public void mCOMMA() // throws RecognitionException [2] - { - try - { - int _type = COMMA; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:771:6: ( ',' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:771:8: ',' - { - Match(','); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "COMMA" - - // $ANTLR start "OPEN" - public void mOPEN() // throws RecognitionException [2] - { - try - { - int _type = OPEN; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:773:5: ( '(' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:773:7: '(' - { - Match('('); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OPEN" - - // $ANTLR start "CLOSE" - public void mCLOSE() // throws RecognitionException [2] - { - try - { - int _type = CLOSE; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:774:6: ( ')' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:774:8: ')' - { - Match(')'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "CLOSE" - - // $ANTLR start "OPEN_BRACKET" - public void mOPEN_BRACKET() // throws RecognitionException [2] - { - try - { - int _type = OPEN_BRACKET; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:775:13: ( '[' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:775:15: '[' - { - Match('['); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "OPEN_BRACKET" - - // $ANTLR start "CLOSE_BRACKET" - public void mCLOSE_BRACKET() // throws RecognitionException [2] - { - try - { - int _type = CLOSE_BRACKET; - int _channel = DEFAULT_TOKEN_CHANNEL; - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:776:14: ( ']' ) - // C:\\CSharp\\NH\\nhibernate\\src\\NHibernate\\Hql\\Ast\\ANTLR\\Hql.g:776:16: ']' - { - Match(']'); if (state.failed) return ; - - } - - state.type = _type; - state.channel = _channel; - } - finally - { - } - } - // $ANTLR end "CLOSE_BRACKET" - - // $ANTLR start "CONCAT" - public void mCONCAT() // throws RecognitionException [2] - { - try - { - int _t... [truncated message content] |
From: <fab...@us...> - 2009-06-20 15:21:53
|
Revision: 4494 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4494&view=rev Author: fabiomaulo Date: 2009-06-20 15:21:09 +0000 (Sat, 20 Jun 2009) Log Message: ----------- Fix NH-1846 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/NHibernateUtil.cs trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Type/DbTimestampType.cs trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/DbVersionFixture.cs trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/Group.cs trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/Permission.cs trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/User.cs trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/User.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-06-20 03:21:45 UTC (rev 4493) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-06-20 15:21:09 UTC (rev 4494) @@ -76,7 +76,20 @@ BindColumns(timestampSchema, simpleValue, propertyName); if (!simpleValue.IsTypeSpecified) - simpleValue.TypeName = NHibernateUtil.Timestamp.Name; + { + switch (timestampSchema.source) + { + case HbmTimestampSource.Vm: + simpleValue.TypeName = NHibernateUtil.Timestamp.Name; + break; + case HbmTimestampSource.Db: + simpleValue.TypeName = NHibernateUtil.DbTimestamp.Name; + break; + default: + simpleValue.TypeName = NHibernateUtil.Timestamp.Name; + break; + } + } var property = new Property(simpleValue); BindProperty(timestampSchema, property, inheritedMetas); Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-20 03:21:45 UTC (rev 4493) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-20 15:21:09 UTC (rev 4494) @@ -604,6 +604,7 @@ <Compile Include="Tool\hbm2ddl\SchemaMetadataUpdater.cs" /> <Compile Include="Transaction\AdoNetWithDistrubtedTransactionFactory.cs" /> <Compile Include="Transform\ToListResultTransformer.cs" /> + <Compile Include="Type\DbTimestampType.cs" /> <Compile Include="Type\DefaultCollectionTypeFactory.cs" /> <Compile Include="Bytecode\ICollectionTypeFactory.cs" /> <Compile Include="Util\NullableDictionary.cs" /> Modified: trunk/nhibernate/src/NHibernate/NHibernateUtil.cs =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-06-20 03:21:45 UTC (rev 4493) +++ trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-06-20 15:21:09 UTC (rev 4494) @@ -224,6 +224,8 @@ /// NHibernate Timestamp type /// </summary> public static readonly NullableType Timestamp = new TimestampType(); + + public static readonly NullableType DbTimestamp = new DbTimestampType(); /// <summary> /// NHibernate TrueFalse type Added: trunk/nhibernate/src/NHibernate/Type/DbTimestampType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/DbTimestampType.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Type/DbTimestampType.cs 2009-06-20 15:21:09 UTC (rev 4494) @@ -0,0 +1,94 @@ +using System; +using System.Data; +using System.Data.Common; +using log4net; +using NHibernate.Engine; +using NHibernate.Exceptions; +using NHibernate.SqlCommand; +using NHibernate.SqlTypes; + +namespace NHibernate.Type +{ + /// <summary> An extension of <see cref="TimestampType"/> which + /// maps to the database's current timestamp, rather than the vm's + /// current timestamp. + /// </summary> + /// <remarks> + /// Note: May/may-not cause issues on dialects which do not properly support + /// a true notion of timestamp + /// </remarks> + [Serializable] + public class DbTimestampType : TimestampType, IVersionType + { + private static readonly ILog log = LogManager.GetLogger(typeof (DbTimestampType)); + private static readonly SqlType[] EmptyParams = new SqlType[0]; + + public override string Name + { + get { return "DbTimestamp"; } + } + + public override object Seed(ISessionImplementor session) + { + if (session == null) + { + log.Debug("incoming session was null; using current vm time"); + return base.Seed(session); + } + else if (!session.Factory.Dialect.SupportsCurrentTimestampSelection) + { + log.Debug("falling back to vm-based timestamp, as dialect does not support current timestamp selection"); + return base.Seed(session); + } + else + { + return GetCurrentTimestamp(session); + } + } + + private object GetCurrentTimestamp(ISessionImplementor session) + { + Dialect.Dialect dialect = session.Factory.Dialect; + string timestampSelectString = dialect.CurrentTimestampSelectString; + return UsePreparedStatement(timestampSelectString, session); + } + + protected virtual object UsePreparedStatement(string timestampSelectString, ISessionImplementor session) + { + var tsSelect = new SqlString(timestampSelectString); + IDbCommand ps = null; + IDataReader rs = null; + try + { + ps = session.Batcher.PrepareCommand(CommandType.Text, tsSelect, EmptyParams); + rs = session.Batcher.ExecuteReader(ps); + rs.Read(); + DateTime ts = rs.GetDateTime(0); + if (log.IsDebugEnabled) + { + log.Debug("current timestamp retreived from db : " + ts + " (tiks=" + ts.Ticks + ")"); + } + return ts; + } + catch (DbException sqle) + { + throw ADOExceptionHelper.Convert(session.Factory.SQLExceptionConverter, sqle, + "could not select current db timestamp", tsSelect); + } + finally + { + if (ps != null) + { + try + { + session.Batcher.CloseCommand(ps, rs); + } + catch (DbException sqle) + { + log.Warn("unable to clean up prepared statement", sqle); + } + } + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-20 03:21:45 UTC (rev 4493) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-20 15:21:09 UTC (rev 4494) @@ -232,6 +232,7 @@ RegisterType(NHibernateUtil.Date, new[] { "date" }); RegisterType(NHibernateUtil.Timestamp, new[] { "timestamp" }); + RegisterType(NHibernateUtil.DbTimestamp, new[] { "dbtimestamp" }); RegisterType(NHibernateUtil.Time, new[] { "time" }); RegisterType(NHibernateUtil.TrueFalse, new[] { "true_false" }); RegisterType(NHibernateUtil.YesNo, new[] { "yes_no" }); Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-20 03:21:45 UTC (rev 4493) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-20 15:21:09 UTC (rev 4494) @@ -1349,11 +1349,15 @@ <Compile Include="UtilityTest\ThreadSafeDictionaryFixture.cs" /> <Compile Include="UtilityTest\TypeNameParserFixture.cs" /> <Compile Include="UtilityTest\WeakHashtableFixture.cs" /> + <Compile Include="VersionTest\Db\DbVersionFixture.cs" /> + <Compile Include="VersionTest\Db\Group.cs" /> <Compile Include="VersionTest\Db\MsSQL\BinaryTimestamp.cs" /> <Compile Include="VersionTest\Db\MsSQL\ComplexDomain.cs" /> <Compile Include="VersionTest\Db\MsSQL\ComplexDomainFixture.cs" /> <Compile Include="VersionTest\Db\MsSQL\GeneratedBinaryVersionFixture.cs" /> <Compile Include="VersionTest\Db\MsSQL\SimpleVersioned.cs" /> + <Compile Include="VersionTest\Db\Permission.cs" /> + <Compile Include="VersionTest\Db\User.cs" /> <Compile Include="VersionTest\Person.cs" /> <Compile Include="VersionTest\Task.cs" /> <Compile Include="VersionTest\Thing.cs" /> @@ -1918,6 +1922,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="VersionTest\Db\User.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1831\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1069\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1837\Mappings.hbm.xml" /> Added: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/DbVersionFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/DbVersionFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/DbVersionFixture.cs 2009-06-20 15:21:09 UTC (rev 4494) @@ -0,0 +1,111 @@ +using System; +using System.Collections; +using System.Threading; +using NUnit.Framework; + +namespace NHibernate.Test.VersionTest.Db +{ + [TestFixture] + public class DbVersionFixture : TestCase + { + protected override IList Mappings + { + get { return new[] {"VersionTest.Db.User.hbm.xml"}; } + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + [Test] + public void CollectionVersion() + { + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + var guy = new User { Username = "guy" }; + s.Persist(guy); + var admin = new Group {Name = "admin"}; + s.Persist(admin); + t.Commit(); + s.Close(); + + DateTime guyTimestamp = guy.Timestamp; + + // For dialects (Oracle8 for example) which do not return "true + // timestamps" sleep for a bit to allow the db date-time increment... + Thread.Sleep(1500); + + s = OpenSession(); + t = s.BeginTransaction(); + guy = s.Get<User>(guy.Id); + admin = s.Get<Group>(admin.Id); + guy.Groups.Add(admin); + admin.Users.Add(guy); + t.Commit(); + s.Close(); + + Assert.That(!NHibernateUtil.Timestamp.IsEqual(guyTimestamp, guy.Timestamp), "owner version not incremented"); + + guyTimestamp = guy.Timestamp; + Thread.Sleep(1500); + + s = OpenSession(); + t = s.BeginTransaction(); + guy = s.Get<User>(guy.Id); + guy.Groups.Clear(); + t.Commit(); + s.Close(); + + Assert.That(!NHibernateUtil.Timestamp.IsEqual(guyTimestamp, guy.Timestamp), "owner version not incremented"); + + s = OpenSession(); + t = s.BeginTransaction(); + s.Delete(s.Load<User>(guy.Id)); + s.Delete(s.Load<Group>(admin.Id)); + t.Commit(); + s.Close(); + } + + [Test] + public void CollectionNoVersion() + { + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + var guy = new User {Username = "guy"}; + s.Persist(guy); + var perm = new Permission {Name = "silly", Access = "user", Context = "rw"}; + s.Persist(perm); + t.Commit(); + s.Close(); + + DateTime guyTimestamp = guy.Timestamp; + + s = OpenSession(); + t = s.BeginTransaction(); + guy = s.Get<User>(guy.Id); + perm = s.Get<Permission>(perm.Id); + guy.Permissions.Add(perm); + t.Commit(); + s.Close(); + + Assert.That(NHibernateUtil.Timestamp.IsEqual(guyTimestamp, guy.Timestamp), "owner version was incremented"); + + s = OpenSession(); + t = s.BeginTransaction(); + guy = s.Get<User>(guy.Id); + guy.Permissions.Clear(); + t.Commit(); + s.Close(); + + Assert.That(NHibernateUtil.Timestamp.IsEqual(guyTimestamp, guy.Timestamp), "owner version was incremented"); + + s = OpenSession(); + t = s.BeginTransaction(); + s.Delete(s.Load<User>(guy.Id)); + s.Delete(s.Load<Permission>(perm.Id)); + t.Commit(); + s.Close(); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/Group.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/Group.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/Group.cs 2009-06-20 15:21:09 UTC (rev 4494) @@ -0,0 +1,16 @@ +using System; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.VersionTest.Db +{ + public class Group + { + public virtual long Id { get; set; } + + public virtual DateTime Timestamp { get; set; } + + public virtual string Name { get; set; } + + public virtual ISet<User> Users { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/Permission.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/Permission.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/Permission.cs 2009-06-20 15:21:09 UTC (rev 4494) @@ -0,0 +1,17 @@ +using System; + +namespace NHibernate.Test.VersionTest.Db +{ + public class Permission + { + public virtual long Id { get; set; } + + public virtual DateTime Timestamp { get; set; } + + public virtual string Name { get; set; } + + public virtual string Context { get; set; } + + public virtual string Access { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/User.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/User.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/User.cs 2009-06-20 15:21:09 UTC (rev 4494) @@ -0,0 +1,18 @@ +using System; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.VersionTest.Db +{ + public class User + { + public virtual long Id { get; set; } + + public virtual DateTime Timestamp { get; set; } + + public virtual string Username { get; set; } + + public virtual ISet<Group> Groups { get; set; } + + public virtual ISet<Permission> Permissions { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/User.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/User.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/User.hbm.xml 2009-06-20 15:21:09 UTC (rev 4494) @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- + Demonstrates how to control the optimistic locking behavior + of a collection (do changes to the collection result in + a version increment on the owning instance) + --> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.VersionTest.Db" + assembly="NHibernate.Test"> + + <class name="User" table="db_vers_user"> + <id name="Id" column="user_id" type="long"> + <generator class="native"/> + </id> + <timestamp name="Timestamp" column="ts" source="db"/> + <property name="Username" column="user_name" type="string" unique="true"/> + <set name="Groups" table="db_vers_user_group" batch-size="9" inverse="true" optimistic-lock="true" lazy="true" cascade="none" > + <key column="user_id"/> + <many-to-many column="group_id" class="Group" lazy="false" fetch="join" /> + </set> + <set name="Permissions" table="db_vers_user_perm" batch-size="9" inverse="false" optimistic-lock="false" lazy="true" cascade="none"> + <key column="user_id"/> + <many-to-many column="perm_id" class="Permission" lazy="false" fetch="join"/> + </set> + </class> + + <class name="Group" table="db_vers_group"> + <id name="Id" column="group_id" type="long"> + <generator class="native"/> + </id> + <timestamp name="Timestamp" column="ts" source="db"/> + <property name="Name" column="name" type="string" unique="true"/> + <set name="Users" table="db_vers_user_group" batch-size="9" inverse="false" lazy="true" cascade="none" > + <key column="group_id"/> + <many-to-many column="user_id" class="User" lazy="false" fetch="join" /> + </set> + </class> + + <class name="Permission" table="db_vers_permission"> + <id name="Id" column="perm_id" type="long"> + <generator class="native"/> + </id> + <timestamp name="Timestamp" column="ts" source="db"/> + <property name="Name" column="name" type="string" unique="true"/> + <property name="Context" column="ctx" type="string"/> + <property name="Access" column="priv" type="string"/> + </class> +</hibernate-mapping> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-21 13:22:12
|
Revision: 4501 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4501&view=rev Author: fabiomaulo Date: 2009-06-21 12:18:09 +0000 (Sun, 21 Jun 2009) Log Message: ----------- Minor (removed some warning) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs Modified: trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs 2009-06-21 11:40:14 UTC (rev 4500) +++ trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs 2009-06-21 12:18:09 UTC (rev 4501) @@ -235,8 +235,8 @@ /// <param name="role">The role the collection is in.</param> /// <param name="propertyRef">The name of the property in the /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.< - /// /param> + /// the primary key. + /// </param> /// <param name="embedded">Is embedded in XML (not supported yet)</param> /// <returns> /// A <see cref="MapType"/> for the specified role. Modified: trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs 2009-06-21 11:40:14 UTC (rev 4500) +++ trunk/nhibernate/src/NHibernate/Engine/Transaction/IIsolatedWork.cs 2009-06-21 12:18:09 UTC (rev 4501) @@ -13,6 +13,7 @@ /// Perform the actual work to be done. /// </summary> /// <param name="connection">The ADP connection to use.</param> + /// <param name="transaction">The active transaction of the connection.</param> void DoWork(IDbConnection connection, IDbTransaction transaction); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs 2009-06-21 11:40:14 UTC (rev 4500) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CaseInsensitiveStringStream.cs 2009-06-21 12:18:09 UTC (rev 4501) @@ -7,7 +7,6 @@ /// Look ahead for tokenizing is all lowercase, whereas the original case of an input stream is preserved. /// Copied from http://www.antlr.org/wiki/pages/viewpage.action?pageId=1782 ///</summary> - [CLSCompliant(false)] internal class CaseInsensitiveStringStream : ANTLRStringStream { public CaseInsensitiveStringStream(string input) : base(input) { } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs 2009-06-21 11:40:14 UTC (rev 4500) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ErrorCounter.cs 2009-06-21 12:18:09 UTC (rev 4501) @@ -9,7 +9,6 @@ /// <summary> /// An error handler that counts parsing errors and warnings. /// </summary> - [CLSCompliant(false)] internal class ErrorCounter : IParseErrorHandler { private static readonly ILog log = LogManager.GetLogger(typeof(ErrorCounter)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-06-21 11:40:14 UTC (rev 4500) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-06-21 12:18:09 UTC (rev 4501) @@ -449,7 +449,6 @@ } } - [CLSCompliant(false)] internal class HqlParseEngine { private static readonly ILog log = LogManager.GetLogger(typeof(HqlParseEngine)); @@ -560,7 +559,6 @@ } } - [CLSCompliant(false)] internal class HqlSqlTranslator { private readonly IASTNode _inputAst; @@ -613,7 +611,6 @@ } } - [CLSCompliant(false)] internal class HqlSqlGenerator { private static readonly ILog log = LogManager.GetLogger(typeof(HqlSqlGenerator)); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-06-21 11:40:14 UTC (rev 4500) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SessionFactoryHelperExtensions.cs 2009-06-21 12:18:09 UTC (rev 4501) @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using NHibernate.Dialect.Function; using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Tree; @@ -14,7 +13,7 @@ namespace NHibernate.Hql.Ast.ANTLR { [CLSCompliant(false)] - internal class SessionFactoryHelperExtensions + public class SessionFactoryHelperExtensions { private readonly ISessionFactoryImplementor _sfi; private readonly NullableDictionary<string, IPropertyMapping> _collectionPropertyMappingByRole; Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-06-21 11:40:14 UTC (rev 4500) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-06-21 12:18:09 UTC (rev 4501) @@ -1684,7 +1684,7 @@ /// If this Session is being Finalized (<c>isDisposing==false</c>) then make sure not /// to call any methods that could potentially bring this Session back to life. /// </remarks> - protected void Dispose(bool isDisposing) + private void Dispose(bool isDisposing) { using (new SessionIdLoggingContext(SessionId)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-23 20:20:19
|
Revision: 4520 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4520&view=rev Author: fabiomaulo Date: 2009-06-23 20:20:18 +0000 (Tue, 23 Jun 2009) Log Message: ----------- Minor refactoring Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/IHibernateConfiguration.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/ISessionFactoryConfiguration.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs 2009-06-23 20:09:53 UTC (rev 4519) +++ trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs 2009-06-23 20:20:18 UTC (rev 4520) @@ -153,7 +153,7 @@ /// The <see cref="SessionFactoryConfiguration"/> if the session-factory exists in hibernate-configuration; /// Otherwise null. /// </summary> - public SessionFactoryConfiguration SessionFactory + public ISessionFactoryConfiguration SessionFactory { get { return sessionFactory; } } Modified: trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs 2009-06-23 20:09:53 UTC (rev 4519) +++ trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs 2009-06-23 20:20:18 UTC (rev 4520) @@ -7,7 +7,7 @@ /// <summary> /// Configuration parsed values for a session-factory XML node. /// </summary> - public class SessionFactoryConfiguration + public class SessionFactoryConfiguration : ISessionFactoryConfiguration { //private static readonly ILog log = LogManager.GetLogger(typeof(SessionFactoryConfiguration)); Modified: trunk/nhibernate/src/NHibernate/Cfg/IHibernateConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/IHibernateConfiguration.cs 2009-06-23 20:09:53 UTC (rev 4519) +++ trunk/nhibernate/src/NHibernate/Cfg/IHibernateConfiguration.cs 2009-06-23 20:20:18 UTC (rev 4520) @@ -1,5 +1,4 @@ -using System; -using NHibernate.Cfg.ConfigurationSchema; +using NHibernate.Cfg.ConfigurationSchema; namespace NHibernate.Cfg { @@ -7,6 +6,6 @@ { BytecodeProviderType ByteCodeProviderType { get; } bool UseReflectionOptimizer { get; } - SessionFactoryConfiguration SessionFactory { get; } + ISessionFactoryConfiguration SessionFactory { get; } } } Added: trunk/nhibernate/src/NHibernate/Cfg/ISessionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/ISessionFactoryConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/ISessionFactoryConfiguration.cs 2009-06-23 20:20:18 UTC (rev 4520) @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using NHibernate.Cfg.ConfigurationSchema; + +namespace NHibernate.Cfg +{ + public interface ISessionFactoryConfiguration { + /// <summary> + /// The session factory name. + /// </summary> + string Name { get; } + + /// <summary> + /// Session factory propeties bag. + /// </summary> + IDictionary<string, string> Properties { get; } + + /// <summary> + /// Session factory mapping configuration. + /// </summary> + IList<MappingConfiguration> Mappings { get; } + + /// <summary> + /// Session factory class-cache configurations. + /// </summary> + IList<ClassCacheConfiguration> ClassesCache { get; } + + /// <summary> + /// Session factory collection-cache configurations. + /// </summary> + IList<CollectionCacheConfiguration> CollectionsCache { get; } + + /// <summary> + /// Session factory event configurations. + /// </summary> + IList<EventConfiguration> Events { get; } + + /// <summary> + /// Session factory listener configurations. + /// </summary> + IList<ListenerConfiguration> Listeners { get; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-23 20:09:53 UTC (rev 4519) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-23 20:20:18 UTC (rev 4520) @@ -459,6 +459,7 @@ <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> + <Compile Include="Cfg\ISessionFactoryConfiguration.cs" /> <Compile Include="Cfg\MappingSchema\AbstractDecoratable.cs" /> <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> <Compile Include="Cfg\MappingSchema\HbmVersion.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-24 03:58:14
|
Revision: 4523 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4523&view=rev Author: fabiomaulo Date: 2009-06-24 03:57:43 +0000 (Wed, 24 Jun 2009) Log Message: ----------- Refactoring (extracted base class) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/SessionFactoryConfigurationBase.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs 2009-06-23 23:23:33 UTC (rev 4522) +++ trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/SessionFactoryConfiguration.cs 2009-06-24 03:57:43 UTC (rev 4523) @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Xml.XPath; namespace NHibernate.Cfg.ConfigurationSchema @@ -7,7 +6,7 @@ /// <summary> /// Configuration parsed values for a session-factory XML node. /// </summary> - public class SessionFactoryConfiguration : ISessionFactoryConfiguration + public class SessionFactoryConfiguration : SessionFactoryConfigurationBase { //private static readonly ILog log = LogManager.GetLogger(typeof(SessionFactoryConfiguration)); @@ -24,7 +23,7 @@ /// <param name="name">The session factory name. Null or empty string are allowed.</param> public SessionFactoryConfiguration(string name) { - this.name = name; + Name = name; } private void Parse(XPathNavigator navigator) @@ -44,7 +43,7 @@ if (xpn != null) { if (xpn.MoveToFirstAttribute()) - name = xpn.Value; + Name = xpn.Value; } } @@ -53,21 +52,12 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryPropertiesExpression); while (xpni.MoveNext()) { - string propName; - string propValue; - if(xpni.Current.Value!=null) - { - propValue = xpni.Current.Value.Trim(); - } - else - { - propValue = string.Empty; - } + string propValue = xpni.Current.Value!=null ? xpni.Current.Value.Trim() : string.Empty; XPathNavigator pNav = xpni.Current.Clone(); pNav.MoveToFirstAttribute(); - propName= pNav.Value; + string propName = pNav.Value; if (!string.IsNullOrEmpty(propName)) - properties[propName] = propValue; + Properties[propName] = propValue; } } @@ -76,29 +66,10 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryMappingsExpression); while (xpni.MoveNext()) { - MappingConfiguration mc = new MappingConfiguration(xpni.Current); + var mc = new MappingConfiguration(xpni.Current); if (!mc.IsEmpty()) { - // Workaround add first an assembly&resource and then only the same assembly. - // the <mapping> of whole assembly is ignored (included only sigles resources) - // The "ignore" log, is enough ? - // Perhaps we can add some intelligence to remove single resource reference when a whole assembly is referenced - //if (!mappings.Contains(mc)) - //{ - // mappings.Add(mc); - //} - //else - //{ - // string logMessage = "Ignored mapping -> " + mc.ToString(); - // if (log.IsDebugEnabled) - // log.Debug(logMessage); - // if (log.IsWarnEnabled) - // log.Warn(logMessage); - //} - - // The control to prevent mappings duplication was removed since the engine do the right thing - // for this issue (simple is better) - mappings.Add(mc); + Mappings.Add(mc); } } } @@ -108,7 +79,7 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryClassesCacheExpression); while (xpni.MoveNext()) { - classesCache.Add(new ClassCacheConfiguration(xpni.Current)); + ClassesCache.Add(new ClassCacheConfiguration(xpni.Current)); } } @@ -118,7 +89,7 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryCollectionsCacheExpression); while (xpni.MoveNext()) { - collectionsCache.Add(new CollectionCacheConfiguration(xpni.Current)); + CollectionsCache.Add(new CollectionCacheConfiguration(xpni.Current)); } } @@ -128,7 +99,7 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryListenersExpression); while (xpni.MoveNext()) { - listeners.Add(new ListenerConfiguration(xpni.Current)); + Listeners.Add(new ListenerConfiguration(xpni.Current)); } } @@ -137,72 +108,8 @@ XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryEventsExpression); while (xpni.MoveNext()) { - events.Add(new EventConfiguration(xpni.Current)); + Events.Add(new EventConfiguration(xpni.Current)); } } - - private string name = string.Empty; - /// <summary> - /// The session factory name. - /// </summary> - public string Name - { - get { return name; } - } - - private IDictionary<string, string> properties = new Dictionary<string, string>(); - /// <summary> - /// Session factory propeties bag. - /// </summary> - public IDictionary<string,string> Properties - { - get { return properties; } - } - - private IList<MappingConfiguration> mappings = new List<MappingConfiguration>(); - /// <summary> - /// Session factory mapping configuration. - /// </summary> - public IList<MappingConfiguration> Mappings - { - get { return mappings; } - } - - private IList<ClassCacheConfiguration> classesCache= new List<ClassCacheConfiguration>(); - /// <summary> - /// Session factory class-cache configurations. - /// </summary> - public IList<ClassCacheConfiguration> ClassesCache - { - get { return classesCache; } - } - - private IList<CollectionCacheConfiguration> collectionsCache= new List<CollectionCacheConfiguration>(); - /// <summary> - /// Session factory collection-cache configurations. - /// </summary> - public IList<CollectionCacheConfiguration> CollectionsCache - { - get { return collectionsCache; } - } - - private IList<EventConfiguration> events= new List<EventConfiguration>(); - /// <summary> - /// Session factory event configurations. - /// </summary> - public IList<EventConfiguration> Events - { - get { return events; } - } - - private IList<ListenerConfiguration> listeners= new List<ListenerConfiguration>(); - /// <summary> - /// Session factory listener configurations. - /// </summary> - public IList<ListenerConfiguration> Listeners - { - get { return listeners; } - } - } } Added: trunk/nhibernate/src/NHibernate/Cfg/SessionFactoryConfigurationBase.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/SessionFactoryConfigurationBase.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/SessionFactoryConfigurationBase.cs 2009-06-24 03:57:43 UTC (rev 4523) @@ -0,0 +1,73 @@ +using System.Collections.Generic; +using NHibernate.Cfg.ConfigurationSchema; + +namespace NHibernate.Cfg +{ + public class SessionFactoryConfigurationBase : ISessionFactoryConfiguration + { + private string name = string.Empty; + private readonly IDictionary<string, string> properties = new Dictionary<string, string>(); + private readonly IList<MappingConfiguration> mappings = new List<MappingConfiguration>(); + private readonly IList<ClassCacheConfiguration> classesCache= new List<ClassCacheConfiguration>(); + private readonly IList<CollectionCacheConfiguration> collectionsCache= new List<CollectionCacheConfiguration>(); + private readonly IList<EventConfiguration> events= new List<EventConfiguration>(); + private readonly IList<ListenerConfiguration> listeners= new List<ListenerConfiguration>(); + + /// <summary> + /// The session factory name. + /// </summary> + public string Name + { + get { return name; } + protected set { name = value; } + } + + /// <summary> + /// Session factory propeties bag. + /// </summary> + public IDictionary<string,string> Properties + { + get { return properties; } + } + + /// <summary> + /// Session factory mapping configuration. + /// </summary> + public IList<MappingConfiguration> Mappings + { + get { return mappings; } + } + + /// <summary> + /// Session factory class-cache configurations. + /// </summary> + public IList<ClassCacheConfiguration> ClassesCache + { + get { return classesCache; } + } + + /// <summary> + /// Session factory collection-cache configurations. + /// </summary> + public IList<CollectionCacheConfiguration> CollectionsCache + { + get { return collectionsCache; } + } + + /// <summary> + /// Session factory event configurations. + /// </summary> + public IList<EventConfiguration> Events + { + get { return events; } + } + + /// <summary> + /// Session factory listener configurations. + /// </summary> + public IList<ListenerConfiguration> Listeners + { + get { return listeners; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-23 23:23:33 UTC (rev 4522) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-24 03:57:43 UTC (rev 4523) @@ -459,6 +459,7 @@ <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> + <Compile Include="Cfg\SessionFactoryConfigurationBase.cs" /> <Compile Include="Cfg\ISessionFactoryConfiguration.cs" /> <Compile Include="Cfg\MappingSchema\AbstractDecoratable.cs" /> <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-24 18:58:46
|
Revision: 4524 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4524&view=rev Author: RicBrown Date: 2009-06-24 18:58:43 +0000 (Wed, 24 Jun 2009) Log Message: ----------- Added first cut of ICriteria<T> interface. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs Added: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-24 18:58:43 UTC (rev 4524) @@ -0,0 +1,32 @@ + +using System; +using System.Linq.Expressions; + +namespace NHibernate +{ + + /// <summary> + /// Criteria<T> is an API for retrieving entities by composing + /// <see cref="Criterion.Expression" /> objects expressed using Lambda expression syntax. + /// </summary> + /// <remarks> + /// <code> + /// IList<Cat> cats = session.QueryOver<Cat>() + /// .Add( c => c.Name == "Tigger" ) + /// .Add( c => c.Weight > minWeight ) ) + /// .List(); + /// </code> + /// </remarks> + public interface ICriteria<T> + { + + /// <summary> + /// Add criterion expressed as a lambda expression + /// </summary> + /// <param name="expression">Lambda expression</param> + /// <returns>criteria instance</returns> + ICriteria<T> Add(Expression<Func<T, bool>> expression); + + } + +} Added: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-24 18:58:43 UTC (rev 4524) @@ -0,0 +1,35 @@ + +using System; +using System.Linq.Expressions; + +namespace NHibernate.Impl +{ + + /// <summary> + /// Implementation of the <see cref="ICriteria<T>"/> interface + /// </summary> + [Serializable] + public class CriteriaImpl<T> : ICriteria<T> + { + + private ICriteria _criteria; + + public CriteriaImpl(ICriteria criteria) + { + _criteria = criteria; + } + + public ICriteria UnderlyingCriteria + { + get { return _criteria; } + } + + ICriteria<T> ICriteria<T>.Add(Expression<Func<T, bool>> expression) + { + _criteria.Add(expression); + return this; + } + + } + +} Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-24 03:57:43 UTC (rev 4523) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-24 18:58:43 UTC (rev 4524) @@ -515,6 +515,8 @@ <Compile Include="Hql\Ast\ANTLR\Tree\ASTErrorNode.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\InsertStatement.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\UpdateStatement.cs" /> + <Compile Include="ICriteriaOfT.cs" /> + <Compile Include="Impl\CriteriaOfTImpl.cs" /> <Compile Include="Impl\ExpressionProcessor.cs" /> <Compile Include="Impl\SessionIdLoggingContext.cs" /> <Compile Include="Param\AbstractExplicitParameterSpecification.cs" /> Added: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-24 18:58:43 UTC (rev 4524) @@ -0,0 +1,34 @@ +using System; +using System.Collections; + +using NUnit.Framework; + +using NHibernate.Criterion; +using NHibernate.Transform; +using NHibernate.Type; +using NHibernate.Util; + +namespace NHibernate.Test.Criteria.Lambda +{ + + [TestFixture] + public class CriteriaOfTFixture : LambdaFixtureBase + { + + [Test] + public void Equality() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .Add(Restrictions.Eq("Name", "test name")); + + ICriteria<Person> actual = + CreateTestCriteria<Person>() + .Add(p => p.Name == "test name"); + + AssertCriteriaAreEqual(expected, actual); + } + + } + +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-06-24 03:57:43 UTC (rev 4523) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-06-24 18:58:43 UTC (rev 4524) @@ -29,6 +29,26 @@ return new CriteriaImpl(persistentClass, alias, null); } + protected ICriteria<T> CreateTestCriteria<T>() + { + return new CriteriaImpl<T>(new CriteriaImpl(typeof(T), null)); + } + + protected void AssertCriteriaAreEqual(ICriteria expected, ICriteria actual) + { + AssertObjectsAreEqual(expected, actual); + } + + protected void AssertCriteriaAreEqual(DetachedCriteria expected, DetachedCriteria actual) + { + AssertObjectsAreEqual(expected, actual); + } + + protected void AssertCriteriaAreEqual<T>(ICriteria expected, ICriteria<T> actual) + { + AssertObjectsAreEqual(expected, ((CriteriaImpl<T>)actual).UnderlyingCriteria); + } + private void AssertDictionariesAreEqual(IDictionary expected, IDictionary actual) { Assert.AreEqual(expected.Keys.Count, actual.Keys.Count, _fieldPath.Peek() + ".Count"); @@ -127,16 +147,6 @@ AssertObjectsAreEqual(expected, actual, expected.GetType().Name); } - protected void AssertCriteriaAreEqual(ICriteria expected, ICriteria actual) - { - AssertObjectsAreEqual(expected, actual); - } - - protected void AssertCriteriaAreEqual(DetachedCriteria expected, DetachedCriteria actual) - { - AssertObjectsAreEqual(expected, actual); - } - } } Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-24 03:57:43 UTC (rev 4523) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-24 18:58:43 UTC (rev 4524) @@ -145,6 +145,7 @@ <Compile Include="Criteria\Enrolment.cs" /> <Compile Include="Criteria\Lambda\CriteriaAssertFixture.cs" /> <Compile Include="Criteria\Lambda\CriteriaFixture.cs" /> + <Compile Include="Criteria\Lambda\CriteriaOfTFixture.cs" /> <Compile Include="Criteria\Lambda\IntegrationFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> <Compile Include="Criteria\Lambda\Model.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-24 19:22:42
|
Revision: 4525 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4525&view=rev Author: RicBrown Date: 2009-06-24 19:22:41 +0000 (Wed, 24 Jun 2009) Log Message: ----------- Added integration test and implementation of Criteria<T> through to the DB. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/ISession.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-24 18:58:43 UTC (rev 4524) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-24 19:22:41 UTC (rev 4525) @@ -1,5 +1,6 @@ using System; +using System.Collections.Generic; using System.Linq.Expressions; namespace NHibernate @@ -27,6 +28,12 @@ /// <returns>criteria instance</returns> ICriteria<T> Add(Expression<Func<T, bool>> expression); + /// <summary> + /// Get the results of the root type and fill the <see cref="IList<T>"/> + /// </summary> + /// <param name="results">The list filled with the results.</param> + IList<T> List(); + } } Modified: trunk/nhibernate/src/NHibernate/ISession.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ISession.cs 2009-06-24 18:58:43 UTC (rev 4524) +++ trunk/nhibernate/src/NHibernate/ISession.cs 2009-06-24 19:22:41 UTC (rev 4525) @@ -783,6 +783,13 @@ ICriteria CreateCriteria(string entityName, string alias); /// <summary> + /// Creates a new <c>ICriteria<T></c> for the entity class. + /// </summary> + /// <typeparam name="T">The entity class</typeparam> + /// <returns>An ICriteria<T> object</returns> + ICriteria<T> QueryOver<T>() where T : class; + + /// <summary> /// Create a new instance of <c>Query</c> for the given query string /// </summary> /// <param name="queryString">A hibernate query string</param> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-24 18:58:43 UTC (rev 4524) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-24 19:22:41 UTC (rev 4525) @@ -1,5 +1,6 @@ using System; +using System.Collections.Generic; using System.Linq.Expressions; namespace NHibernate.Impl @@ -30,6 +31,11 @@ return this; } + IList<T> ICriteria<T>.List() + { + return _criteria.List<T>(); + } + } } Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-06-24 18:58:43 UTC (rev 4524) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-06-24 19:22:41 UTC (rev 4525) @@ -1871,6 +1871,14 @@ } } + public ICriteria<T> QueryOver<T>() where T : class + { + using (new SessionIdLoggingContext(SessionId)) + { + return new CriteriaImpl<T>(CreateCriteria(typeof(T))); + } + } + public override IList List(CriteriaImpl criteria) { using (new SessionIdLoggingContext(SessionId)) Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-24 18:58:43 UTC (rev 4524) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-24 19:22:41 UTC (rev 4525) @@ -66,6 +66,30 @@ } } + [Test] + public void ICriteriaOfT_SimpleCriterion() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new Person() { Name = "test person 1" }); + s.Save(new Person() { Name = "test person 2" }); + s.Save(new Person() { Name = "test person 3" }); + + t.Commit(); + } + + using (ISession s = OpenSession()) + { + IList<Person> actual = + s.QueryOver<Person>() + .Add(p => p.Name == "test person 2") + .List(); + + Assert.That(actual.Count, Is.EqualTo(1)); + } + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-24 19:58:09
|
Revision: 4526 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4526&view=rev Author: RicBrown Date: 2009-06-24 19:58:07 +0000 (Wed, 24 Jun 2009) Log Message: ----------- Renamed ICriteria<T>.Add to ICriteria<T>.And (.Where to come). Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-24 19:22:41 UTC (rev 4525) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-24 19:58:07 UTC (rev 4526) @@ -26,7 +26,7 @@ /// </summary> /// <param name="expression">Lambda expression</param> /// <returns>criteria instance</returns> - ICriteria<T> Add(Expression<Func<T, bool>> expression); + ICriteria<T> And(Expression<Func<T, bool>> expression); /// <summary> /// Get the results of the root type and fill the <see cref="IList<T>"/> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-24 19:22:41 UTC (rev 4525) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-24 19:58:07 UTC (rev 4526) @@ -25,7 +25,7 @@ get { return _criteria; } } - ICriteria<T> ICriteria<T>.Add(Expression<Func<T, bool>> expression) + ICriteria<T> ICriteria<T>.And(Expression<Func<T, bool>> expression) { _criteria.Add(expression); return this; Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-24 19:22:41 UTC (rev 4525) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-24 19:58:07 UTC (rev 4526) @@ -24,7 +24,7 @@ ICriteria<Person> actual = CreateTestCriteria<Person>() - .Add(p => p.Name == "test name"); + .And(p => p.Name == "test name"); AssertCriteriaAreEqual(expected, actual); } Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-24 19:22:41 UTC (rev 4525) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-24 19:58:07 UTC (rev 4526) @@ -83,7 +83,7 @@ { IList<Person> actual = s.QueryOver<Person>() - .Add(p => p.Name == "test person 2") + .And(p => p.Name == "test person 2") .List(); Assert.That(actual.Count, Is.EqualTo(1)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-24 20:48:45
|
Revision: 4527 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4527&view=rev Author: RicBrown Date: 2009-06-24 20:48:32 +0000 (Wed, 24 Jun 2009) Log Message: ----------- Added ICriteria<T>.Where() to allow more natural queries. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-24 19:58:07 UTC (rev 4526) +++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-24 20:48:32 UTC (rev 4527) @@ -29,6 +29,13 @@ ICriteria<T> And(Expression<Func<T, bool>> expression); /// <summary> + /// Identical semantics to Add() to allow more readable queries + /// </summary> + /// <param name="expression">Lambda expression</param> + /// <returns>criteria instance</returns> + ICriteria<T> Where(Expression<Func<T, bool>> expression); + + /// <summary> /// Get the results of the root type and fill the <see cref="IList<T>"/> /// </summary> /// <param name="results">The list filled with the results.</param> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-24 19:58:07 UTC (rev 4526) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-24 20:48:32 UTC (rev 4527) @@ -31,6 +31,12 @@ return this; } + ICriteria<T> ICriteria<T>.Where(Expression<Func<T, bool>> expression) + { + _criteria.Add(expression); + return this; + } + IList<T> ICriteria<T>.List() { return _criteria.List<T>(); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-24 19:58:07 UTC (rev 4526) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-24 20:48:32 UTC (rev 4527) @@ -72,9 +72,9 @@ using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) { - s.Save(new Person() { Name = "test person 1" }); - s.Save(new Person() { Name = "test person 2" }); - s.Save(new Person() { Name = "test person 3" }); + s.Save(new Person() { Name = "test person 1", Age = 20 }); + s.Save(new Person() { Name = "test person 2", Age = 30 }); + s.Save(new Person() { Name = "test person 3", Age = 40 }); t.Commit(); } @@ -83,7 +83,8 @@ { IList<Person> actual = s.QueryOver<Person>() - .And(p => p.Name == "test person 2") + .Where(p => p.Name == "test person 2") + .And(p => p.Age == 30) .List(); Assert.That(actual.Count, Is.EqualTo(1)); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml 2009-06-24 19:58:07 UTC (rev 4526) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml 2009-06-24 20:48:32 UTC (rev 4527) @@ -8,6 +8,7 @@ <generator class="native"/> </id> <property name="Name" /> + <property name="Age" /> </class> <class name="Child"> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-24 19:58:07 UTC (rev 4526) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-24 20:48:32 UTC (rev 4527) @@ -9,6 +9,7 @@ { public virtual int Id { get; set; } public virtual string Name { get; set; } + public virtual int Age { get; set; } } public class Child This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-25 03:50:33
|
Revision: 4528 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4528&view=rev Author: fabiomaulo Date: 2009-06-25 03:50:31 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Proof of concept of Loquacious session-factory configuration. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbSchemaIntegrationConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IFluentSessionFactoryConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IBatcherConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,9 @@ +using NHibernate.AdoNet; +namespace NHibernate.Cfg.Loquacious +{ + public interface IBatcherConfiguration + { + IBatcherConfiguration Trough<TBatcher>() where TBatcher : IBatcherFactory; + IDbIntegrationConfiguration Each(short batchSize); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICacheConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,12 @@ +using NHibernate.Cache; +namespace NHibernate.Cfg.Loquacious +{ + public interface ICacheConfiguration + { + ICacheConfiguration Trough<TProvider>() where TProvider : ICacheProvider; + ICacheConfiguration PrefixingRegionsWith(string regionPrefix); + ICacheConfiguration UsingMinimalPuts(); + IFluentSessionFactoryConfiguration WithDefaultExpiration(byte seconds); + IQueryCacheConfiguration Queries { get; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICollectionFactoryConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,8 @@ +using NHibernate.Bytecode; +namespace NHibernate.Cfg.Loquacious +{ + public interface ICollectionFactoryConfiguration + { + IFluentSessionFactoryConfiguration Trough<TCollecionsFactory>() where TCollecionsFactory : ICollectionTypeFactory; + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,21 @@ +using NHibernate.Exceptions; +namespace NHibernate.Cfg.Loquacious +{ + public interface ICommandsConfiguration + { + ICommandsConfiguration Preparing(); + ICommandsConfiguration WithTimeout(int seconds); + ICommandsConfiguration ConvertingExpetionsTrough<TExceptionConverter>() where TExceptionConverter : ISQLExceptionConverter; + ICommandsConfiguration AutoCommentingSql(); + IDbIntegrationConfiguration WithHqlToSqlSubstitutions(string csvQuerySubstitutions); + IDbIntegrationConfiguration WithDefaultHqlToSqlSubstitutions(); + + /// <summary> + /// Maximum depth of outer join fetching + /// </summary> + /// <remarks> + /// 0 (zero) disable the usage of OuterJoinFetching + /// </remarks> + ICommandsConfiguration WithMaximumDepthOfOuterJoinFetching(byte maxFetchDepth); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IConnectionConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,18 @@ +using System.Data; +using System.Data.Common; +using NHibernate.Driver; +using NHibernate.Connection; + +namespace NHibernate.Cfg.Loquacious +{ + public interface IConnectionConfiguration + { + IConnectionConfiguration Trough<TProvider>() where TProvider : IConnectionProvider; + IConnectionConfiguration Through<TDriver>() where TDriver : IDriver; + IConnectionConfiguration With(IsolationLevel level); + IConnectionConfiguration Releasing(ConnectionReleaseMode releaseMode); + IDbIntegrationConfiguration Using(string connectionString); + IDbIntegrationConfiguration Using(DbConnectionStringBuilder connectionStringBuilder); + IDbIntegrationConfiguration ByAppConfing(string connectionStringName); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,27 @@ +namespace NHibernate.Cfg.Loquacious +{ + public interface IDbIntegrationConfiguration + { + /// <summary> + /// Define the dialect to use. + /// </summary> + /// <typeparam name="TDialect">The dialect implementation inherited from <see cref="Dialect.Dialect"/>. </typeparam> + /// <returns>The fluent configuration itself.</returns> + IDbIntegrationConfiguration Using<TDialect>() where TDialect : Dialect.Dialect; + IDbIntegrationConfiguration DisableKeywordsAutoImport(); + IDbIntegrationConfiguration AutoQuoteKeywords(); + IDbIntegrationConfiguration LogSqlInConsole(); + IDbIntegrationConfiguration DisableLogFormatedSql(); + + IConnectionConfiguration Connected { get; } + + IBatcherConfiguration BatchingQueries { get; } + + ITransactionConfiguration Transactions { get; } + + ICommandsConfiguration CreateCommands { get; } + + IDbSchemaIntegrationConfiguration Schema { get; } + + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbSchemaIntegrationConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbSchemaIntegrationConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbSchemaIntegrationConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,10 @@ +namespace NHibernate.Cfg.Loquacious +{ + public interface IDbSchemaIntegrationConfiguration + { + IDbIntegrationConfiguration Recreating(); + IDbIntegrationConfiguration Creating(); + IDbIntegrationConfiguration Updating(); + IDbIntegrationConfiguration Validating(); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IFluentSessionFactoryConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IFluentSessionFactoryConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IFluentSessionFactoryConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,36 @@ +using NHibernate.Hql; +namespace NHibernate.Cfg.Loquacious +{ + public interface IFluentSessionFactoryConfiguration + { + /// <summary> + /// Set the SessionFactory mnemonic name. + /// </summary> + /// <param name="sessionFactoryName">The mnemonic name.</param> + /// <returns>The fluent configuration itself.</returns> + /// <remarks> + /// The SessionFactory mnemonic name can be used as a surrogate key in a multi-DB application. + /// </remarks> + IFluentSessionFactoryConfiguration Named(string sessionFactoryName); + + /// <summary> + /// DataBase integration configuration. + /// </summary> + IDbIntegrationConfiguration Integrate { get; } + + /// <summary> + /// Cache configuration. + /// </summary> + ICacheConfiguration Caching { get; } + + IFluentSessionFactoryConfiguration GenerateStatistics(); + IFluentSessionFactoryConfiguration Using(EntityMode entityMode); + IFluentSessionFactoryConfiguration ParsingHqlThrough<TQueryTranslator>() where TQueryTranslator : IQueryTranslatorFactory; + + IProxyConfiguration Proxy { get; } + + ICollectionFactoryConfiguration GeneratingCollections { get; } + + IMappingsConfiguration Mapping { get; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IMappingsConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,8 @@ +namespace NHibernate.Cfg.Loquacious +{ + public interface IMappingsConfiguration + { + IMappingsConfiguration UsingDefaultSchema(string defaultSchemaName); + IMappingsConfiguration UsingDefaultCatalog(string defaultCatalogName); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IProxyConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,9 @@ +using NHibernate.Bytecode; +namespace NHibernate.Cfg.Loquacious +{ + public interface IProxyConfiguration + { + IProxyConfiguration DisableValidation(); + IFluentSessionFactoryConfiguration Trough<TProxyFactoryFactory>() where TProxyFactoryFactory : IProxyFactoryFactory; + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IQueryCacheConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,9 @@ +using NHibernate.Cache; + +namespace NHibernate.Cfg.Loquacious +{ + public interface IQueryCacheConfiguration + { + ICacheConfiguration Trough<TFactory>() where TFactory : IQueryCache; + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ITransactionConfiguration.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,8 @@ +using NHibernate.Transaction; +namespace NHibernate.Cfg.Loquacious +{ + public interface ITransactionConfiguration + { + IDbIntegrationConfiguration Trough<TFactory>() where TFactory : ITransactionFactory; + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-24 20:48:32 UTC (rev 4527) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-25 03:50:31 UTC (rev 4528) @@ -459,6 +459,18 @@ <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> + <Compile Include="Cfg\Loquacious\IBatcherConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\ICacheConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\ICollectionFactoryConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\ICommandsConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\IConnectionConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\IDbIntegrationConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\IDbSchemaIntegrationConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\IFluentSessionFactoryConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\IMappingsConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\IProxyConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\IQueryCacheConfiguration.cs" /> + <Compile Include="Cfg\Loquacious\ITransactionConfiguration.cs" /> <Compile Include="Cfg\SessionFactoryConfigurationBase.cs" /> <Compile Include="Cfg\ISessionFactoryConfiguration.cs" /> <Compile Include="Cfg\MappingSchema\AbstractDecoratable.cs" /> Added: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-25 03:50:31 UTC (rev 4528) @@ -0,0 +1,74 @@ +using System.Data; +using NHibernate.AdoNet; +using NHibernate.ByteCode.LinFu; +using NHibernate.Cache; +using NHibernate.Cfg.Loquacious; +using NHibernate.Dialect; +using NHibernate.Driver; +using NHibernate.Exceptions; +using NHibernate.Hql.Classic; +using NHibernate.Type; + +namespace NHibernate.Test.CfgTest.Loquacious +{ + public class ConfigurationFixture + { + public void ProofOfConcept() + { + // Here I'm configuring near all properties outside the scope of Configuration class + // Using the Configuration class the user can add mappings and configure listeners + IFluentSessionFactoryConfiguration sfc= null; + sfc.Named("SomeName") + .Integrate + .Using<MsSql2000Dialect>() + .AutoQuoteKeywords() + .BatchingQueries + .Trough<SqlClientBatchingBatcherFactory>() + .Each(10) + .Connected + .Trough<DebugConnectionProvider>() + .Through<SqlClientDriver>() + .Releasing(ConnectionReleaseMode.AfterTransaction) + .With(IsolationLevel.ReadCommitted) + .Using("The connection string but it has some overload") + .CreateCommands + .AutoCommentingSql() + .ConvertingExpetionsTrough<SQLStateConverter>() + .Preparing() + .WithTimeout(10) + .WithMaximumDepthOfOuterJoinFetching(10) + .WithHqlToSqlSubstitutions("true 1, false 0, yes 'Y', no 'N'") + .Schema + .Validating() + ; + sfc.Caching + .Trough<HashtableCacheProvider>() + .PrefixingRegionsWith("xyz") + .Queries + .Trough<StandardQueryCache>() + .UsingMinimalPuts() + .WithDefaultExpiration(15) + .GeneratingCollections + .Trough<DefaultCollectionTypeFactory>() + .Proxy + .DisableValidation() + .Trough<ProxyFactoryFactory>() + .ParsingHqlThrough<ClassicQueryTranslatorFactory>() + .Mapping + .UsingDefaultCatalog("MyCatalog") + .UsingDefaultSchema("MySche") + ; + } + + public void ProofOfConceptMinimalConfiguration() + { + // This is a possible minimal configuration + // in this case we must define best default properties for each dialect + // The place where put default properties values is the Dialect itself. + IFluentSessionFactoryConfiguration sfc = null; + sfc + .Proxy.Trough<ProxyFactoryFactory>() + .Integrate.Using<MsSql2005Dialect>(); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-24 20:48:32 UTC (rev 4527) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-25 03:50:31 UTC (rev 4528) @@ -107,6 +107,7 @@ <Compile Include="CfgTest\HbmBinderFixture.cs" /> <Compile Include="CfgTest\HbmOrderingFixture.cs" /> <Compile Include="CfgTest\LocatedInTestAssembly.cs" /> + <Compile Include="CfgTest\Loquacious\ConfigurationFixture.cs" /> <Compile Include="CfgTest\MappingDocumentAggregatorTests.cs" /> <Compile Include="CfgTest\MappingDocumentParserTests.cs" /> <Compile Include="CfgTest\SettingsFactoryFixture.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-25 04:19:43
|
Revision: 4530 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4530&view=rev Author: fabiomaulo Date: 2009-06-25 04:19:42 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Fixed TYPO Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs 2009-06-25 04:13:07 UTC (rev 4529) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/ICommandsConfiguration.cs 2009-06-25 04:19:42 UTC (rev 4530) @@ -5,7 +5,7 @@ { ICommandsConfiguration Preparing(); ICommandsConfiguration WithTimeout(int seconds); - ICommandsConfiguration ConvertingExpetionsTrough<TExceptionConverter>() where TExceptionConverter : ISQLExceptionConverter; + ICommandsConfiguration ConvertingExceptionsTrough<TExceptionConverter>() where TExceptionConverter : ISQLExceptionConverter; ICommandsConfiguration AutoCommentingSql(); IDbIntegrationConfiguration WithHqlToSqlSubstitutions(string csvQuerySubstitutions); IDbIntegrationConfiguration WithDefaultHqlToSqlSubstitutions(); Modified: trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-25 04:13:07 UTC (rev 4529) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs 2009-06-25 04:19:42 UTC (rev 4530) @@ -33,7 +33,7 @@ .Using("The connection string but it has some overload") .CreateCommands .AutoCommentingSql() - .ConvertingExpetionsTrough<SQLStateConverter>() + .ConvertingExceptionsTrough<SQLStateConverter>() .Preparing() .WithTimeout(10) .WithMaximumDepthOfOuterJoinFetching(10) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |