/**
 * Copyright 2011 Xeiam LLC.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.xeiam.yank.example;

import java.util.List;

import com.xeiam.yank.DBProxy;

/**
 * DAO Class for BOOKS table
 * 
 * @author timmolter
 */
public class BooksDAO {

  public static int insertBook(Book pBook) {

    Object[] params = new Object[] { pBook.getTitle(), pBook.getAuthor(), pBook.getPrice() };
    String SQL = "INSERT INTO BOOKS  (TITLE, AUTHOR, PRICE) VALUES (?, ?, ?)";
    return DBProxy.executeIUDSQL("local", SQL, params);
  }

  public static List<Book> selectAllBooks() {

    String SQL = "SELECT * FROM BOOKS";
    return (List<Book>) DBProxy.queryBeanListSQL("local", SQL, null, Book.class);
  }

  public static int[] insertBatch(List<Book> pBooks) {

    Object[][] params = new Object[pBooks.size()][];

    for (int i = 0; i < pBooks.size(); i++) {
      Book book = pBooks.get(i);
      params[i] = new Object[] { book.getTitle(), book.getAuthor(), book.getPrice() };
    }

    String SQL = "INSERT INTO BOOKS  (TITLE, AUTHOR, PRICE) VALUES (?, ?, ?)";
    return DBProxy.executeBatchIUDSQL("local", SQL, params);
  }

  public static int createBooksTable() {

    String SQL = "CREATE TABLE `Books` (`TITLE` varchar(42) DEFAULT NULL, `AUTHOR` varchar(42) DEFAULT NULL,`PRICE` double DEFAULT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
    return DBProxy.executeIUDSQL("local", SQL, null);
  }

  public static Book selectBook(String pTitle) {

    Object[] params = new Object[] { pTitle };
    return (Book) DBProxy.querySingleBeanSQLKey("local", "BOOKS_SELECT_BY_TITLE", params, Book.class);
  }

  public static List<Object[]> getTableStatus() {

    return DBProxy.queryObjectListSQLKey("local", "BOOKS_SELECT_TABLE_STATUS", null);
  }

}

@@ -1001,35 +1001,32 @@
  DBProxy.execute
-IUD
 SQL(%22local%22, SQL
@@ -1028,32 +1028,32 @@
 , SQL, params);%0A
+
   %7D%0A%0A  public st
@@ -1165,20 +1165,22 @@
 xy.query
-Bean
+Object
 ListSQL(
@@ -1610,19 +1610,16 @@
 uteBatch
-IUD
 SQL(%22loc
@@ -1889,11 +1889,8 @@
 cute
-IUD
 SQL(
@@ -2053,12 +2053,14 @@
 ngle
-Bean
+Object
 SQLK
@@ -2193,30 +2193,42 @@
 BProxy.query
+Generic
 Object
+Array
 ListSQLKey(%22

rename refactor