aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate
diff options
context:
space:
mode:
authorSean Dague2008-04-08 02:50:44 +0000
committerSean Dague2008-04-08 02:50:44 +0000
commit32b8dd70d69e500e38c4bd7ae146a36767061979 (patch)
treeb217b1d19f030d809a92d42c894483465fbe2b8e /OpenSim/Data/NHibernate
parent* Adds poor support for ellipsis in the Meshmerizer. This will get better.. ... (diff)
downloadopensim-SC_OLD-32b8dd70d69e500e38c4bd7ae146a36767061979.zip
opensim-SC_OLD-32b8dd70d69e500e38c4bd7ae146a36767061979.tar.gz
opensim-SC_OLD-32b8dd70d69e500e38c4bd7ae146a36767061979.tar.bz2
opensim-SC_OLD-32b8dd70d69e500e38c4bd7ae146a36767061979.tar.xz
attempt to introduce custom LLUUIDString type for
NHibernate
Diffstat (limited to 'OpenSim/Data/NHibernate')
-rw-r--r--OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml2
-rw-r--r--OpenSim/Data/NHibernate/Types/LLUUIDType.cs78
2 files changed, 79 insertions, 1 deletions
diff --git a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml
index bf2cda7..71f498c 100644
--- a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml
@@ -1,7 +1,7 @@
1<?xml version="1.0" encoding="utf-8" ?> 1<?xml version="1.0" encoding="utf-8" ?>
2<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> 2<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
3 <class name="OpenSim.Framework.AssetBase, OpenSim.Framework" table="Assets" lazy="false"> 3 <class name="OpenSim.Framework.AssetBase, OpenSim.Framework" table="Assets" lazy="false">
4 <id name="ID" column="UUID" type="String" length="40" > 4 <id name="FullID" column="UUID" type="OpenSim.Data.NHibernate.LLUUIDString">
5 <generator class="assigned" /> 5 <generator class="assigned" />
6 </id> 6 </id>
7 <property name="Type" type="SByte" /> 7 <property name="Type" type="SByte" />
diff --git a/OpenSim/Data/NHibernate/Types/LLUUIDType.cs b/OpenSim/Data/NHibernate/Types/LLUUIDType.cs
new file mode 100644
index 0000000..21d3774
--- /dev/null
+++ b/OpenSim/Data/NHibernate/Types/LLUUIDType.cs
@@ -0,0 +1,78 @@
1using System;
2using System.Data;
3using NHibernate.SqlTypes;
4using NHibernate.UserTypes;
5using libsecondlife;
6
7namespace OpenSim.Data.NHibernate
8{
9 [Serializable]
10 public class LLUUIDString : IUserType
11 {
12 public object Assemble(object cached, object owner)
13 {
14 return cached;
15 }
16
17 bool IUserType.Equals(object uuid1, object uuid2)
18 {
19 return uuid1.Equals(uuid2);
20 }
21
22 public object DeepCopy(object uuid)
23 {
24 return uuid;
25 }
26
27 public object Disassemble(object uuid)
28 {
29 return uuid;
30 }
31
32 public int GetHashCode(object uuid)
33 {
34 return (uuid == null) ? 0 : uuid.GetHashCode();
35 }
36
37 public bool IsMutable
38 {
39 get { return false; }
40 }
41
42 public object NullSafeGet(System.Data.IDataReader rs, string[] names, object owner)
43 {
44 object uuid = null;
45
46 int ord = rs.GetOrdinal(names[0]);
47 if (!rs.IsDBNull(ord))
48 {
49 string first = (string)rs.GetString(ord);
50 uuid = new LLUUID(first);
51 }
52
53 return uuid;
54 }
55
56 public void NullSafeSet(System.Data.IDbCommand cmd, object obj, int index)
57 {
58 LLUUID UUID = (LLUUID)obj;
59 ((IDataParameter)cmd.Parameters[index]).Value = UUID.ToString();
60 }
61
62 public object Replace(object original, object target, object owner)
63 {
64 return original;
65 }
66
67 public Type ReturnedType
68 {
69 get { return typeof(LLUUID); }
70 }
71
72 public SqlType[] SqlTypes
73 {
74 // I think we're up to 36
75 get { return new SqlType [] { SqlTypeFactory.GetString(36) }; }
76 }
77 }
78}