// Path: yodao/src/main/java/com/yoda/yodao/DaoFactory.java
// public final class DaoFactory {
// 
//     private static final String SUFFIX = "Impl";
// 
//     private static Map<String, SoftReference<Class<?>>> mClazzCache = new HashMap<>();
// 
//     public static void onCreateTable(SQLiteDatabase db) {
//         // create(HairDao.class).onCreateTable(db);
//         // create(PhotoDao.class).onCreateTable(db);
//     }
// 
//     public static void onUpgradeTable(SQLiteDatabase db, int oldVersion,
//                                       int newVersion) {
//         // create(HairDao.class).onUpgradeTable(db, oldVersion, newVersion);
//         // create(PhotoDao.class).onUpgradeTable(db, oldVersion, newVersion);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public static <T> T create(Class<T> daoClass, SQLiteOpenHelper openHelper) {
//         String daoClassName = daoClass.getCanonicalName();
//         String[] cls = parseToClazz(daoClassName);
//         daoClassName = cls[0] + ".impl." + cls[1] + SUFFIX;
//         try {
//             Class<?> clazz = null;
//             SoftReference<Class<?>> ref = mClazzCache.get(daoClassName);
//             if (ref != null) {
//                 clazz = ref.get();
//             }
//             if (clazz == null) {
//                 clazz = Class.forName(daoClassName);
//                 mClazzCache.put(daoClassName, new SoftReference<Class<?>>(clazz));
//             }
// 
//             if (openHelper != null) {
//                 Constructor<?> constructor = clazz
//                         .getConstructor(SQLiteOpenHelper.class);
//                 return (T) constructor.newInstance(openHelper);
//             } else {
//                 return (T) clazz.newInstance();
//             }
//         } catch (ClassNotFoundException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (NoSuchMethodException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (SecurityException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (InstantiationException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (IllegalAccessException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (IllegalArgumentException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (InvocationTargetException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         }
//     }
// 
//     public static String[] parseToClazz(String clazzName) {
//         int index = clazzName.lastIndexOf(".");
//         if (index == -1) {
//             throw new IllegalArgumentException(
//                     "model's package name must has at last one `.`");
//         }
//         String packageName = clazzName.substring(0, index);
//         String className = clazzName.substring(index + 1, clazzName.length());
//         return new String[] { packageName, className };
//     }
// 
// }
// 
// Path: yodao-examples/src/main/java/com/yoda/yodao/example/dao/HairDao.java
// @Repository
// public abstract class HairDao extends BaseDao<Hair, Long> {
// 
// 	public HairDao(SQLiteOpenHelper openHelper) {
// 		super(openHelper);
// 	}
// 
// }
// 
// Path: yodao-examples/src/main/java/com/yoda/yodao/example/dao/PhotoDao.java
// @Repository
// public interface PhotoDao extends YoDao<Photo, String> {
// 
// 	List<Photo> findListByViewType(int type);
// 
// 	List<Photo> findListByModelingUUId(String mid);
// 
// 	long countByOpStatus(int opStatus);
// 	
// 	int updateByViewType(Photo entity, int type);
// 	
// 	@Query("select * from photo where type = ?")
// 	Photo findBySQL(int type);
// 
// 	@Query("select * from photo where type = ?")
// 	List<Photo> findListBySQL(int type);
// 
// 	@Query("select count(*) from photo where type = ? and name = ?")
// 	long countBySQL(int type, String name);
// 
// }


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import com.yoda.yodao.DaoFactory;
import com.yoda.yodao.example.dao.HairDao;
import com.yoda.yodao.example.dao.PhotoDao;
package com.yoda.yodao.example;



/**
 * 
 * @author wellor
 * @version
 * @date 2015-3-25
 * 
 */
public class MySQLiteOpenHelper extends android.database.sqlite.SQLiteOpenHelper {

    private static final String DB_NAME = "ibeauty.db";

    private static final int DB_VERSION = 13;

    private static MySQLiteOpenHelper sInstance;

    public MySQLiteOpenHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        DaoFactory.create(HairDao.class, null).onCreateTable(db);
// Path: yodao/src/main/java/com/yoda/yodao/DaoFactory.java
// public final class DaoFactory {
// 
//     private static final String SUFFIX = "Impl";
// 
//     private static Map<String, SoftReference<Class<?>>> mClazzCache = new HashMap<>();
// 
//     public static void onCreateTable(SQLiteDatabase db) {
//         // create(HairDao.class).onCreateTable(db);
//         // create(PhotoDao.class).onCreateTable(db);
//     }
// 
//     public static void onUpgradeTable(SQLiteDatabase db, int oldVersion,
//                                       int newVersion) {
//         // create(HairDao.class).onUpgradeTable(db, oldVersion, newVersion);
//         // create(PhotoDao.class).onUpgradeTable(db, oldVersion, newVersion);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public static <T> T create(Class<T> daoClass, SQLiteOpenHelper openHelper) {
//         String daoClassName = daoClass.getCanonicalName();
//         String[] cls = parseToClazz(daoClassName);
//         daoClassName = cls[0] + ".impl." + cls[1] + SUFFIX;
//         try {
//             Class<?> clazz = null;
//             SoftReference<Class<?>> ref = mClazzCache.get(daoClassName);
//             if (ref != null) {
//                 clazz = ref.get();
//             }
//             if (clazz == null) {
//                 clazz = Class.forName(daoClassName);
//                 mClazzCache.put(daoClassName, new SoftReference<Class<?>>(clazz));
//             }
// 
//             if (openHelper != null) {
//                 Constructor<?> constructor = clazz
//                         .getConstructor(SQLiteOpenHelper.class);
//                 return (T) constructor.newInstance(openHelper);
//             } else {
//                 return (T) clazz.newInstance();
//             }
//         } catch (ClassNotFoundException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (NoSuchMethodException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (SecurityException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (InstantiationException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (IllegalAccessException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (IllegalArgumentException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         } catch (InvocationTargetException e) {
//             throw new IllegalArgumentException(daoClassName + " cann't found.");
//         }
//     }
// 
//     public static String[] parseToClazz(String clazzName) {
//         int index = clazzName.lastIndexOf(".");
//         if (index == -1) {
//             throw new IllegalArgumentException(
//                     "model's package name must has at last one `.`");
//         }
//         String packageName = clazzName.substring(0, index);
//         String className = clazzName.substring(index + 1, clazzName.length());
//         return new String[] { packageName, className };
//     }
// 
// }
// 
// Path: yodao-examples/src/main/java/com/yoda/yodao/example/dao/HairDao.java
// @Repository
// public abstract class HairDao extends BaseDao<Hair, Long> {
// 
// 	public HairDao(SQLiteOpenHelper openHelper) {
// 		super(openHelper);
// 	}
// 
// }
// 
// Path: yodao-examples/src/main/java/com/yoda/yodao/example/dao/PhotoDao.java
// @Repository
// public interface PhotoDao extends YoDao<Photo, String> {
// 
// 	List<Photo> findListByViewType(int type);
// 
// 	List<Photo> findListByModelingUUId(String mid);
// 
// 	long countByOpStatus(int opStatus);
// 	
// 	int updateByViewType(Photo entity, int type);
// 	
// 	@Query("select * from photo where type = ?")
// 	Photo findBySQL(int type);
// 
// 	@Query("select * from photo where type = ?")
// 	List<Photo> findListBySQL(int type);
// 
// 	@Query("select count(*) from photo where type = ? and name = ?")
// 	long countBySQL(int type, String name);
// 
// }


// Path: yodao-examples/src/main/java/com/yoda/yodao/example/MySQLiteOpenHelper.java
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import com.yoda.yodao.DaoFactory;
import com.yoda.yodao.example.dao.HairDao;
import com.yoda.yodao.example.dao.PhotoDao;

package com.yoda.yodao.example;



/**
 * 
 * @author wellor
 * @version
 * @date 2015-3-25
 * 
 */
public class MySQLiteOpenHelper extends android.database.sqlite.SQLiteOpenHelper {

    private static final String DB_NAME = "ibeauty.db";

    private static final int DB_VERSION = 13;

    private static MySQLiteOpenHelper sInstance;

    public MySQLiteOpenHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        DaoFactory.create(HairDao.class, null).onCreateTable(db);
        DaoFactory.create(PhotoDao.class, null).onCreateTable(db);