Hi all
I have an assembly called PersistentData containing the following class:
Code:
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 try to use it as a custom id generator like this:
Code:
<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:
Quote:
Could not interpret id generator strategy: PersistentData.UUIDGenerator. Possible cause: no assembly name specified.
Does anyone know what's the problem?