package com.melt.sample.dao;

import com.melt.orm.criteria.Criteria;
import com.melt.orm.session.Session;
import com.melt.orm.session.SessionFactory;

import java.util.List;

public abstract class GenericDao<T> {
    private SessionFactory sessionFactory;

    public int insert(T t) {
        return getSession().insert(t);
    }

    public List<T> find(Criteria criteria) {
        return getSession().find(getModelClass(), criteria);
    }

    public T findById(int id) {
        return getSession().findById(getModelClass(), id);
    }

    public void delete(Criteria criteria) {
        getSession().delete(getModelClass(), criteria);
    }


    public void update(T t, Criteria criteria) {
        //TODO
    }



    protected Session getSession() {
        return sessionFactory.createSession();
    }

    protected abstract Class getModelClass();

    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }
}

@@ -643,17 +643,16 @@
 %0A    %7D%0A%0A
-%0A
     publ
@@ -704,22 +704,49 @@
     
-//TODO
+getSession().update(t, criteria);
 %0A    %7D%0A%0A
 %0A%0A  
@@ -741,18 +741,16 @@
 %0A    %7D%0A%0A
-%0A%0A
     prot

add update customer in sample