|
| 1 | +using System.Data; |
| 2 | +using System.Data.Common; |
| 3 | +using NHibernate.Dialect.Schema; |
| 4 | +using Environment = NHibernate.Cfg.Environment; |
| 5 | + |
| 6 | +namespace NHibernate.Dialect |
| 7 | +{ |
| 8 | + /// <remarks> |
| 9 | + /// The SapSQLAnywhere17Dialect uses the SybaseSQLAnywhere12Dialect as its |
| 10 | + /// base class. SybaseSQLAnywhere17Dialect includes support for ISO SQL standard |
| 11 | + /// sequences, which are defined in the catalog table <tt>SYSSEQUENCE</tt>. |
| 12 | + /// The dialect uses the SybaseSQLAnywhe12MetaData class for metadata API |
| 13 | + /// calls, which correctly supports reserved words defined by SQL Anywhere. |
| 14 | + /// |
| 15 | + /// The dialect defaults the following configuration properties: |
| 16 | + /// <list type="table"> |
| 17 | + /// <listheader> |
| 18 | + /// <term>Property</term> |
| 19 | + /// <description>Default Value</description> |
| 20 | + /// </listheader> |
| 21 | + /// <item> |
| 22 | + /// <term>connection.driver_class</term> |
| 23 | + /// <description><see cref="NHibernate.Driver.SapSQLAnywhere17Driver" /></description> |
| 24 | + /// </item> |
| 25 | + /// <item> |
| 26 | + /// <term>prepare_sql</term> |
| 27 | + /// <description><see langword="false" /></description> |
| 28 | + /// </item> |
| 29 | + /// </list> |
| 30 | + /// </remarks> |
| 31 | + public class SapSQLAnywhere17Dialect : SybaseSQLAnywhere12Dialect |
| 32 | + { |
| 33 | + public SapSQLAnywhere17Dialect() |
| 34 | + : base() |
| 35 | + { |
| 36 | + DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.SybaseSQLAnywhere17Driver"; |
| 37 | + } |
| 38 | + |
| 39 | + protected override void RegisterKeywords() |
| 40 | + { |
| 41 | + base.RegisterKeywords(); |
| 42 | + } |
| 43 | + |
| 44 | + protected override void RegisterDateTimeTypeMappings() |
| 45 | + { |
| 46 | + base.RegisterDateTimeTypeMappings(); |
| 47 | + } |
| 48 | + |
| 49 | + /// <summary> |
| 50 | + /// SQL Anywhere supports <tt>SEQUENCES</tt> using a primarily SQL Standard |
| 51 | + /// syntax. Sequence values can be queried using the <tt>.CURRVAL</tt> identifier, and the next |
| 52 | + /// value in a sequence can be retrieved using the <tt>.NEXTVAL</tt> identifier. Sequences |
| 53 | + /// are retained in the SYS.SYSSEQUENCE catalog table. |
| 54 | + /// </summary> |
| 55 | + public override bool SupportsSequences |
| 56 | + { |
| 57 | + get { return true; } |
| 58 | + } |
| 59 | + |
| 60 | + /// <summary> |
| 61 | + /// Pooled sequences does not refer to the CACHE parameter of the <tt>CREATE SEQUENCE</tt> |
| 62 | + /// statement, but merely if the DBMS supports sequences that can be incremented or decremented |
| 63 | + /// by values greater than 1. |
| 64 | + /// </summary> |
| 65 | + public override bool SupportsPooledSequences |
| 66 | + { |
| 67 | + get { return true; } |
| 68 | + } |
| 69 | + |
| 70 | + /// <summary>Get the <tt>SELECT</tt> command used to retrieve the names of all sequences.</summary> |
| 71 | + /// <returns>The <tt>SELECT</tt> command; or NULL if sequences are not supported.</returns> |
| 72 | + public override string QuerySequencesString |
| 73 | + { |
| 74 | + get { return "SELECT SEQUENCE_NAME FROM SYS.SYSSEQUENCE"; } |
| 75 | + } |
| 76 | + |
| 77 | + public override string GetSequenceNextValString(string sequenceName) |
| 78 | + { |
| 79 | + return "SELECT " + GetSelectSequenceNextValString(sequenceName) + " FROM SYS.DUMMY"; |
| 80 | + } |
| 81 | + |
| 82 | + public override string GetSelectSequenceNextValString(string sequenceName) |
| 83 | + { |
| 84 | + return sequenceName + ".NEXTVAL"; |
| 85 | + } |
| 86 | + |
| 87 | + public override string GetCreateSequenceString(string sequenceName) |
| 88 | + { |
| 89 | + return "CREATE SEQUENCE " + sequenceName; // by default, is START WITH 1 MAXVALUE 2**63-1 |
| 90 | + } |
| 91 | + |
| 92 | + public override string GetDropSequenceString(string sequenceName) |
| 93 | + { |
| 94 | + return "DROP SEQUENCE " + sequenceName; |
| 95 | + } |
| 96 | + |
| 97 | + public override IDataBaseSchema GetDataBaseSchema(DbConnection connection) |
| 98 | + { |
| 99 | + return new SybaseAnywhereDataBaseMetaData(connection); |
| 100 | + } |
| 101 | + } |
| 102 | +} |
0 commit comments