google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

no release version & basicDAO puzzle #370

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am use morphia-1.00-SNAPSHOTS.

i got two puzzle:

1. maven repository seems have no release version of morphia. only snapshots.
2. Why BasicDAO has a default constructor. what if i want to implement basicDao 
and init it myself ? 

Original issue reported on code.google.com by XmuF...@gmail.com on 31 Jan 2012 at 5:53

GoogleCodeExporter commented 9 years ago
sorry the point 2 is : Why BasicDAO does not has a default constructor. what if 
i want to implement basicDao and init it myself ? 

Original comment by XmuF...@gmail.com on 31 Jan 2012 at 5:54

GoogleCodeExporter commented 9 years ago
My implement is something like :

@Component
public abstract class WrappedMongoDao<T, K> extends BasicDAO<T, K> {

    @Autowired
    private Morphia morphia;

    @Autowired
    private Mongo mongo;

    @SuppressWarnings("unchecked")
    public WrappedMongoDao() {
        // we will construct BasicDao by hand.
        super(null);

        Class<?> clazz = ReflectionUtils.getSuperClassGenricType(getClass());
        Collection collection = clazz.getAnnotation(Collection.class);
        String name = collection.name();

        // do construct
        initDS(mongo, morphia, name);
        initType((Class<T>) clazz);
    }
}

Original comment by XmuF...@gmail.com on 31 Jan 2012 at 5:56