Inherited PersistentObjects not written to Dao.xml with SpringDaoGen


First I would like to congratulate you on a world class framework. Thank you.
I hit a stumbling block with the SpringDaoGen.
I have a Person class that inherits from PersistentObject.
I then have a Contact class that inherits from Person.
SpringDaoGen only checks the immediate base type for PersistentObject.
My fix is shown below.
It involves a helper method that recursively checks the Base types for PersistentObject.
This method call then forms part of the linq query in GetPersistentObjectsFrom
    private static bool isPersistentObject(Type t) 
        if ((t.BaseType.FullName == typeof(PersistentObject).FullName) ||
                && t.BaseType.GetGenericTypeDefinition().FullName == typeof(PersistentObjectWithTypedId<>).FullName))
            return true;
            if (t.BaseType != typeof(Object))
                return isPersistentObject(t.BaseType);
            return false;
    private static IEnumerable<Type> GetPersistentObjectsFrom(string assemblyPath) {
        currentAssemblyPath = assemblyPath;
        // fetch assembly with classes that derive from PersistentObject<>
        AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve +=
            new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);
        Assembly a = System.Reflection.Assembly.ReflectionOnlyLoadFrom(assemblyPath);
        // fetch all types from specified assembly that inherit from PersistentObject or Persistobject<>
        var types = from t in a.GetTypes()
                    where t.IsClass
                        && isPersistentObject(t)
                    select t;
Closed Jul 11, 2008 at 11:34 PM by wmccafferty
This is no longer applicable in version 0.7 which has dropped Spring.NET.


wmccafferty wrote Jul 8, 2008 at 7:35 PM

Thanks very much for this submission...I'll be adding it to the codebase.

wrote Jul 11, 2008 at 11:34 PM

wrote Feb 14, 2013 at 12:39 AM

wrote May 16, 2013 at 6:08 AM