Hi all
I have an assembly called PersistentData containing the following
class:
namespace PersistentData
{
public class UUIDGenerator : IIdentifierGenerator
{
public const int TYPE_PREFIX_LENGTH = 8;
public const string PERSISTENT_OBJECT_PREFIX = "persistn";
private static IDictionary<Type, string> _typeToPrefix = new
Dictionary<Type, string>();
private static IDictionary<string, Type> _prefixToType = new
Dictionary<string, Type>();
static UUIDGenerator()
{
_typeToPrefix[typeof(IPersistentObject)] =
PERSISTENT_OBJECT_PREFIX;
_prefixToType[PERSISTENT_OBJECT_PREFIX] = typeof
(IPersistentObject);
}
public static void registerType(Type type, string prefix)
{
_typeToPrefix[type] = prefix;
_prefixToType[prefix] = type;
}
public static Type getTypeByUUID(string uuid)
{
return _prefixToType[uuid.Substring(0,
TYPE_PREFIX_LENGTH)];
}
public object Generate(ISessionImplementor session, object
obj)
{
var type = obj.GetType();
while (!_typeToPrefix.ContainsKey(type) || type != typeof
(object))
{
type = type.BaseType;
}
return _typeToPrefix[type] + "-" + Guid.NewGuid();
}
}
}
And I'm trying to use it as a custom id generator like this:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="PersistentData" namespace="PersistentData">
<class name="IPersistentObject" table="TBL_PERSISTENT_OBJECTS"
abstract="true" >
<id name="uuid">
<column name="UUID"/>
<generator class="PersistentData.UUIDGenerator"/>
</id>
</class>
</hibernate-mapping>
But when BuildSessionFactory() is called it throws an exception:
Could not interpret id generator strategy:
PersistentData.UUIDGenerator. Possible cause: no assembly name
specified.
Does anyone know what's the problem?
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.