forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOracle10gDialect.cs
70 lines (62 loc) · 2.24 KB
/
Oracle10gDialect.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System.Collections.Generic;
using System.Data;
using NHibernate.Cfg;
using NHibernate.Dialect.Function;
using NHibernate.SqlCommand;
using NHibernate.SqlTypes;
using NHibernate.Util;
namespace NHibernate.Dialect
{
/// <summary>
/// A dialect specifically for use with Oracle 10g.
/// </summary>
/// <remarks>
/// The main difference between this dialect and <see cref="Oracle9iDialect"/>
/// is the use of "ANSI join syntax" here...
/// </remarks>
public class Oracle10gDialect : Oracle9iDialect
{
private bool _useBinaryFloatingPointTypes;
public override JoinFragment CreateOuterJoinFragment()
{
return new ANSIJoinFragment();
}
public override void Configure(IDictionary<string, string> settings)
{
_useBinaryFloatingPointTypes = PropertiesHelper.GetBoolean(
Environment.OracleUseBinaryFloatingPointTypes,
settings,
false);
base.Configure(settings);
}
// Avoid registering weighted double type when using binary floating point types
protected override void RegisterFloatingPointTypeMappings()
{
if (_useBinaryFloatingPointTypes)
{
// Use binary_float (available since 10g) instead of float. With Oracle, float is a decimal but
// with a precision expressed in number of bytes instead of digits.
RegisterColumnType(DbType.Single, "binary_float");
// Using binary_double (available since 10g) instead of double precision. With Oracle, double
// precision is a float(126), which is a decimal with a 126 bytes precision.
RegisterColumnType(DbType.Double, "binary_double");
}
else
{
base.RegisterFloatingPointTypeMappings();
}
}
protected override void RegisterFunctions()
{
base.RegisterFunctions();
// DBMS_RANDOM package was available in previous versions, but it was requiring initialization and
// was not having the value function.
// It yields a decimal between 0 included and 1 excluded, with 38 significant digits. It sometimes
// causes an overflow when read by the Oracle provider as a .Net Decimal, so better explicitly cast
// it to double.
RegisterFunction("random", new SQLFunctionTemplate(NHibernateUtil.Double, "cast(DBMS_RANDOM.VALUE() as binary_double)"));
}
/// <inheritdoc />
public override bool SupportsCrossJoin => true;
}
}