001package gu.sql2java;
002import java.util.List;
003
004import gu.sql2java.exception.ObjectRetrievalException;
005import gu.sql2java.exception.RuntimeDaoException;
006
007import java.util.Collection;
008/**
009 * Interface to handle database calls (save, load, count, etc...) for table.
010 * @author guyadong
011 */
012public interface TableManager<B extends BaseBean> extends SqlRunner{
013
014    public interface Action<B>{
015
016        /**
017         * do action for {@code bean}
018         * @param bean input bean
019         */
020        void call(B bean);
021    }
022        /**
023         * interface for iterate
024         */
025        public interface DoEach<B>{
026                /**
027                 * do action for {@code bean}<br>
028                 * <b>NOTE:</b><br>DO NOT run  deletion operation in the method
029                 * @param bean
030                 * @return remove the row if {@code true}
031                 * @throws Exception 
032                 */
033                boolean doEach(B bean) throws Exception;
034        }
035    /**
036         * Creates a new B instance.
037         *
038         * @return the new B instance
039         */
040        public B createBean();
041
042        //_____________________________________________________________________
043    //
044    // COUNT
045    //_____________________________________________________________________
046    //24
047    /**
048     * Retrieves the number of rows of the table.
049     *
050     * @return the number of rows returned
051     * @throws RuntimeDaoException
052     */
053    public int countAll()throws RuntimeDaoException;
054    
055    //27
056    /**
057     * count the number of elements of a specific bean
058     *
059     * @param bean the bean to look for ant count
060     * @return the number of rows returned
061     * @throws RuntimeDaoException
062     */
063    public int countUsingTemplate( B bean)throws RuntimeDaoException;
064  
065    //20
066    /**
067     * count the number of elements of a specific bean given the search type
068     *
069     * @param bean the template to look for
070     * @param searchType exact ?  like ? starting like ? ending link ? <br>
071     *                {@value Constant#SEARCH_EXACT}   {@link Constant#SEARCH_EXACT} <br>
072     *                {@value Constant#SEARCH_LIKE}   {@link Constant#SEARCH_LIKE} <br>
073     *                {@value Constant#SEARCH_STARTING_LIKE}   {@link Constant#SEARCH_STARTING_LIKE} <br>
074     *                {@value Constant#SEARCH_ENDING_LIKE}   {@link Constant#SEARCH_ENDING_LIKE} <br>  
075     * @return the number of rows returned
076     * @throws RuntimeDaoException
077     */
078    public int countUsingTemplate(B bean, int searchType)throws RuntimeDaoException;
079
080    //25
081    /**
082     * Retrieves the number of rows of the table with a 'where' clause.
083     * It is up to you to pass the 'WHERE' in your where clauses.
084     *
085     * @param where the restriction clause
086     * @return the number of rows returned
087     * @throws RuntimeDaoException
088     */
089    public int countWhere(String where)throws RuntimeDaoException;
090
091    //10
092    /**
093     * Deletes all rows from table.
094     * @return the number of deleted rows.
095     * @throws RuntimeDaoException
096     */
097    public int deleteAll()throws RuntimeDaoException;
098
099    //11
100    /**
101     * Deletes rows from the table using a 'where' clause.
102     * It is up to you to pass the 'WHERE' in your where clauses.
103     * <br>Attention, if 'WHERE' is omitted it will delete all records.
104     *
105     * @param where the sql 'where' clause
106     * @return the number of deleted rows
107     * @throws RuntimeDaoException
108     */
109    public int deleteByWhere(String where)throws RuntimeDaoException;
110
111    //21
112    /**
113     * Deletes rows using a template.
114     *
115     * @param bean the template object(s) to be deleted
116     * @return the number of deleted objects
117     * @throws RuntimeDaoException
118     */
119    public int deleteUsingTemplate(B bean)throws RuntimeDaoException;
120
121    //2.1
122    /**
123     * Delete row according to its primary keys.
124     *
125     * @param keys primary keys value<br>
126     *      for fd_face table<br>
127     *          PK# 1 fd_face.id type Integer<br>
128     *      for fd_feature table<br>
129     *          PK# 1 fd_feature.md5 type String<br>
130     *      for fd_image table<br>
131     *          PK# 1 fd_image.md5 type String<br>
132     *      for fd_store table<br>
133     *          PK# 1 fd_store.md5 type String<br>
134     * @return the number of deleted rows
135     * @throws RuntimeDaoException
136     */   
137    public int deleteByPrimaryKey(Object ...keys)throws RuntimeDaoException;
138
139    //2.2
140    /**
141     * Delete row according to primary keys of bean.<br>
142     * 
143     * @param bean will be deleted ,all keys must not be null
144     * @return the number of deleted rows,0 returned if bean is null
145     * @throws RuntimeDaoException
146     */
147    public int delete(B bean)throws RuntimeDaoException;
148
149    //2.4
150        /**
151         * Delete beans.<br>
152         *
153         * @param beans B array will be deleted
154         * @return the number of deleted rows
155         * @throws RuntimeDaoException
156         */
157    @SuppressWarnings("unchecked")
158        public int delete(B... beans)throws RuntimeDaoException;
159    
160    //2.5  
161        /**
162         * Delete beans.<br>
163         *
164         * @param beans B collection will be deleted
165         * @return the number of deleted rows
166         * @throws RuntimeDaoException
167         */
168        public int delete(Collection<B> beans)throws RuntimeDaoException;
169    //////////////////////////////////////
170    // LOAD ALL
171    //////////////////////////////////////
172
173    //5
174    /**
175     * Loads all the rows from table.
176     *
177     * @return an array of B bean
178     * @throws RuntimeDaoException
179     */
180    public B[] loadAll()throws RuntimeDaoException;
181
182    //5-1    
183    /**
184     * Loads each row from table and dealt with action.
185     * @param action  Action object for do something(not null)
186     * @return the count dealt by action
187     * @throws RuntimeDaoException
188     */
189    public int loadAll(Action<B> action)throws RuntimeDaoException;
190
191    //6
192    /**
193     * Loads the given number of rows from table, given the start row.
194     *
195     * @param startRow the start row to be used (first row = 1, last row = -1)
196     * @param numRows the number of rows to be retrieved (all rows = a negative number)
197     * @return an array of B bean
198     * @throws RuntimeDaoException
199     */
200    public B[] loadAll(int startRow, int numRows)throws RuntimeDaoException;
201
202    //6-1    
203    /**
204     *  Loads the given number of rows from table, given the start row and dealt with action.
205     * @param startRow the start row to be used (first row = 1, last row = -1)
206     * @param numRows the number of rows to be retrieved (all rows = a negative number)
207     * @param action  Action object for do something(not null)
208     * @return the count dealt by action
209     * @throws RuntimeDaoException
210     */
211    public int loadAll(int startRow, int numRows,Action<B> action)throws RuntimeDaoException;
212
213    //5-2
214    /**
215     * Loads all the rows from table.
216     *
217     * @return a list of B bean
218     * @throws RuntimeDaoException
219     */
220    public List<B> loadAllAsList()throws RuntimeDaoException;
221
222    //6-2
223    /**
224     * Loads the given number of rows from table, given the start row.
225     *
226     * @param startRow the start row to be used (first row = 1, last row = -1)
227     * @param numRows the number of rows to be retrieved (all rows = a negative number)
228     * @return a list of B bean
229     * @throws RuntimeDaoException
230     */
231    public List<B> loadAllAsList(int startRow, int numRows)throws RuntimeDaoException;
232
233    //1.2
234    /**
235     * Loads a B bean from the table using primary key fields of {@code bean}.
236     * @param bean the B bean with primary key fields
237     * @return a unique B or {@code null} if not found or bean is null
238     * @throws RuntimeDaoException
239     */
240    public B loadByPrimaryKey(B bean)throws RuntimeDaoException;
241    
242    //1.2.2
243    /**
244     * see also {@link #loadByPrimaryKey(BaseBean)} 
245     * @param bean
246     * @return a unique B ,otherwise throw exception
247     * @throws ObjectRetrievalException not found
248     * @throws RuntimeDaoException
249     */
250    public B loadByPrimaryKeyChecked(B bean)throws RuntimeDaoException,ObjectRetrievalException;
251    //1.3
252    /**
253     * Loads a B bean from the table using primary key fields.
254     * when you don't know which is primary key of table,you can use the method.
255     * @param keys primary keys value:<br> 
256     *      for fd_face table<br>
257     *          PK# 1 fd_face.id type Integer<br>
258     *      for fd_feature table<br>
259     *          PK# 1 fd_feature.md5 type String<br>
260     *      for fd_image table<br>
261     *          PK# 1 fd_image.md5 type String<br>
262     *      for fd_store table<br>
263     *          PK# 1 fd_store.md5 type String<br>
264     * @return a unique B or {@code null} if not found
265     * @throws RuntimeDaoException
266     */
267    public B loadByPrimaryKey(Object ...keys)throws RuntimeDaoException;
268
269    //1.3.2
270    /**
271     * see also {@link #loadByPrimaryKey(Object...)}
272     * @param keys
273     * @return a unique B,otherwise throw exception
274     * @throws ObjectRetrievalException not found
275     * @throws RuntimeDaoException
276     */
277    public B loadByPrimaryKeyChecked(Object ...keys)throws RuntimeDaoException,ObjectRetrievalException;
278    
279    //1.5
280    /**
281     * Returns true if this table contains row with primary key fields.
282     * @param keys primary keys value
283     * @see #loadByPrimaryKey(Object...)
284     * @return 
285     * @throws RuntimeDaoException
286     */
287    public boolean existsPrimaryKey(Object ...keys)throws RuntimeDaoException;
288    
289    //1.6
290    /**
291     * Returns true if this table contains row specified by primary key fields of B.<br>
292     * when you don't know which is primary key of table,you can use the method.
293     * @param bean the B bean with primary key fields
294     * @return 
295     * @see #loadByPrimaryKey(BaseBean)
296     * @throws RuntimeDaoException
297     */
298    public boolean existsByPrimaryKey(B bean)throws RuntimeDaoException;
299    //1.7
300    /**
301     * Check duplicated row by primary keys,if row exists throw exception
302     * @param bean the B bean with primary key fields
303     * @return always bean
304     * @see #existsByPrimaryKey(BaseBean)
305     * @throws ObjectRetrievalException has duplicated record
306     * @throws RuntimeDaoException
307     */
308    public B checkDuplicate(B bean)throws RuntimeDaoException,ObjectRetrievalException;
309   
310    //////////////////////////////////////
311    // SQL 'WHERE' METHOD
312    //////////////////////////////////////
313    //7 
314    /**
315     * Retrieves an array of B given a sql 'where' clause.
316     *
317     * @param where the sql 'where' clause
318     * @return 
319     * @throws RuntimeDaoException
320     */
321    public B[] loadByWhere(String where)throws RuntimeDaoException;
322    
323    //7-1
324    /**
325     * Retrieves each row of B bean given a sql 'where' clause and dealt with action.
326     * @param where the sql 'where' clause
327     * @param action  Action object for do something(not null)
328     * @return the count dealt by action
329     * @throws RuntimeDaoException
330     */
331    public int loadByWhere(String where,Action<B> action)throws RuntimeDaoException;
332
333    //8
334    /**
335     * Retrieves an array of B bean given a sql where clause, and a list of fields.
336     * It is up to you to pass the 'WHERE' in your where clauses.
337     *
338     * @param where the sql 'WHERE' clause
339     * @param fieldList array of field's ID
340     * @return 
341     * @throws RuntimeDaoException
342     */
343    public B[] loadByWhere(String where, int[] fieldList)throws RuntimeDaoException;
344   
345    //8-1 
346    /**
347     * Retrieves each row of B bean given a sql where clause, and a list of fields,
348     * and dealt with action.
349     * It is up to you to pass the 'WHERE' in your where clauses.
350     * @param where the sql 'WHERE' clause
351     * @param fieldList array of field's ID
352     * @param action Action object for do something(not null)
353     * @return the count dealt by action
354     * @throws RuntimeDaoException
355     */
356    public int loadByWhere(String where, int[] fieldList,Action<B> action)throws RuntimeDaoException;
357
358    //9
359    /**
360     * Retrieves an array of B bean given a sql where clause and a list of fields, and startRow and numRows.
361     * It is up to you to pass the 'WHERE' in your where clauses.
362     *
363     * @param where the sql 'where' clause
364     * @param fieldList table of the field's associated constants
365     * @param startRow the start row to be used (first row = 1, last row = -1)
366     * @param numRows the number of rows to be retrieved (all rows = a negative number)
367     * @return 
368     * @throws RuntimeDaoException
369     */
370    public B[] loadByWhere(String where, int[] fieldList, int startRow, int numRows)throws RuntimeDaoException;
371
372    //9-1    
373    /**
374     * Retrieves each row of B bean given a sql where clause and a list of fields, and startRow and numRows,
375     * and dealt with action.
376     * It is up to you to pass the 'WHERE' in your where clauses.
377     *
378     * @param where the sql 'where' clause
379     * @param fieldList table of the field's associated constants
380     * @param startRow the start row to be used (first row = 1, last row = -1)
381     * @param numRows the number of rows to be retrieved (all rows = a negative number)
382     * @param action Action object for do something(not null)
383     * @return the count dealt by action
384     * @throws RuntimeDaoException
385     */
386    public int loadByWhere(String where, int[] fieldList, int startRow, int numRows,Action<B> action)throws RuntimeDaoException;
387    //7
388    /**
389     * Retrieves a list of B bean given a sql 'where' clause.
390     *
391     * @param where the sql 'where' clause
392     * @return
393     * @throws RuntimeDaoException
394     */
395    public List<B> loadByWhereAsList(String where)throws RuntimeDaoException;
396
397    //8
398    /**
399     * Retrieves a list of B bean given a sql where clause, and a list of fields.
400     * It is up to you to pass the 'WHERE' in your where clauses.
401     *
402     * @param where the sql 'WHERE' clause
403     * @param fieldList array of field's ID
404     * @return
405     * @throws RuntimeDaoException
406     */
407    public List<B> loadByWhereAsList(String where, int[] fieldList)throws RuntimeDaoException;
408    
409    //9-2
410    /**
411     * Retrieves a list of B bean given a sql where clause and a list of fields, and startRow and numRows.
412     * It is up to you to pass the 'WHERE' in your where clauses.
413     *
414     * @param where the sql 'where' clause
415     * @param fieldList table of the field's associated constants
416     * @param startRow the start row to be used (first row = 1, last row = -1)
417     * @param numRows the number of rows to be retrieved (all rows = a negative number)
418     * @return
419     * @throws RuntimeDaoException
420     */
421    public List<B> loadByWhereAsList(String where, int[] fieldList, int startRow, int numRows)throws RuntimeDaoException;
422
423    //9-3
424    /**
425     * Retrieves each row of B bean given a sql where clause and a list of fields, and startRow and numRows,
426     * and dealt wity action
427     * It is up to you to pass the 'WHERE' in your where clauses.
428     *
429     * @param where the sql 'where' clause
430     * @param fieldList table of the field's associated constants
431     * @param startRow the start row to be used (first row = 1, last row = -1)
432     * @param numRows the number of rows to be retrieved (all rows = a negative number)
433     * @param action Action object for do something(not null)
434     * @return the count dealt by action
435     * @throws RuntimeDaoException
436     */
437    public int loadByWhereForAction(String where, int[] fieldList, int startRow, int numRows,Action<B> action)throws RuntimeDaoException;
438
439    //_____________________________________________________________________
440    //
441    // USING TEMPLATE
442    //_____________________________________________________________________
443    //18   
444    /**
445     * Loads a unique B bean from a template one giving a c
446     *
447     * @param bean the B bean to look for
448     * @return the bean matching the template,or {@code null} if not found or null input argument
449     * @throws ObjectRetrievalException more than one row
450     * @throws RuntimeDaoException
451     */
452    public B loadUniqueUsingTemplate(B bean)throws RuntimeDaoException;
453
454    //18-1
455    /**
456     * Loads a unique B bean from a template one giving a c
457     *
458     * @param bean the B bean to look for
459     * @return the bean matching the template
460     * @throws ObjectRetrievalException not found or more than one row
461     * @throws RuntimeDaoException
462     */
463    public B loadUniqueUsingTemplateChecked(B bean)throws RuntimeDaoException,ObjectRetrievalException;
464
465    //19
466    /**
467     * Loads an array of B from a template one.
468     *
469     * @param bean the B bean template to look for
470     * @return all the B beans matching the template
471     * @throws RuntimeDaoException
472     */
473    public B[] loadUsingTemplate(B bean)throws RuntimeDaoException;
474    
475    //19-1
476    /**
477     * Loads each row from a template one and dealt with action.
478     *
479     * @param bean the B bean template to look for
480     * @param action Action object for do something(not null)
481     * @return the count dealt by action
482     * @throws RuntimeDaoException
483     */
484    public int loadUsingTemplate(B bean,Action<B> action)throws RuntimeDaoException;
485
486    //20
487    /**
488     * Loads an array of B bean from a template one, given the start row and number of rows.
489     *
490     * @param bean the B bean template to look for
491     * @param startRow the start row to be used (first row = 1, last row=-1)
492     * @param numRows the number of rows to be retrieved (all rows = a negative number)
493     * @return all the B matching the template
494     * @throws RuntimeDaoException
495     */
496    public B[] loadUsingTemplate(B bean, int startRow, int numRows)throws RuntimeDaoException;
497    
498    //20-1
499    /**
500     * Loads each row from a template one, given the start row and number of rows and dealt with action.
501     *
502     * @param bean the B bean template to look for
503     * @param startRow the start row to be used (first row = 1, last row=-1)
504     * @param numRows the number of rows to be retrieved (all rows = a negative number)
505     * @param action Action object for do something(not null)
506     * @return the count dealt by action
507     * @throws RuntimeDaoException
508     */
509    public int loadUsingTemplate(B bean, int startRow, int numRows,Action<B> action)throws RuntimeDaoException;
510
511    //20-5
512    /**
513     * Loads each row from a template one, given the start row and number of rows and dealt with action.
514     *
515     * @param bean the B template to look for
516     * @param fieldList table of the field's associated constants
517     * @param startRow the start row to be used (first row = 1, last row=-1)
518     * @param numRows the number of rows to be retrieved (all rows = a negative number)
519     * @param searchType exact ?  like ? starting like ? ending link ? <br>
520     *                {@value Constant#SEARCH_EXACT}   {@link Constant#SEARCH_EXACT} <br>
521     *                {@value Constant#SEARCH_LIKE}   {@link Constant#SEARCH_LIKE} <br>
522     *                {@value Constant#SEARCH_STARTING_LIKE}   {@link Constant#SEARCH_STARTING_LIKE} <br>
523     *                {@value Constant#SEARCH_ENDING_LIKE}   {@link Constant#SEARCH_ENDING_LIKE} <br>  
524     * @param action Action object for do something(not null)
525     * @return the count dealt by action
526     * @throws RuntimeDaoException
527     */
528    public int loadUsingTemplate(B bean, int[] fieldList, int startRow, int numRows,int searchType, Action<B> action)throws RuntimeDaoException;
529    //20-4
530    /**
531     * Loads a list of B bean from a template one, given the start row and number of rows.
532     *
533     * @param bean the B bean template to look for
534     * @param startRow the start row to be used (first row = 1, last row=-1)
535     * @param numRows the number of rows to be retrieved (all rows = a negative number)
536     * @param searchType exact ?  like ? starting like ? ending link ? <br>
537     *                {@value Constant#SEARCH_EXACT}   {@link Constant#SEARCH_EXACT} <br>
538     *                {@value Constant#SEARCH_LIKE}   {@link Constant#SEARCH_LIKE} <br>
539     *                {@value Constant#SEARCH_STARTING_LIKE}   {@link Constant#SEARCH_STARTING_LIKE} <br>
540     *                {@value Constant#SEARCH_ENDING_LIKE}   {@link Constant#SEARCH_ENDING_LIKE} <br>  
541     * @return all the B bean matching the template
542     * @throws RuntimeDaoException
543     */
544    public B[] loadUsingTemplate(B bean, int startRow, int numRows, int searchType)throws RuntimeDaoException;
545
546    //19-2
547    /**
548     * Loads a list of B bean from a template one.
549     *
550     * @param bean the B bean template to look for
551     * @return all the B beans matching the template
552     * @throws RuntimeDaoException
553     */
554    public List<B> loadUsingTemplateAsList(B bean)throws RuntimeDaoException;
555
556    //20-2
557    /**
558     * Loads a list of B bean from a template one, given the start row and number of rows.
559     *
560     * @param bean the B bean template to look for
561     * @param startRow the start row to be used (first row = 1, last row=-1)
562     * @param numRows the number of rows to be retrieved (all rows = a negative number)
563     * @return all the B bean matching the template
564     * @throws RuntimeDaoException
565     */
566    public List<B> loadUsingTemplateAsList(B bean, int startRow, int numRows)throws RuntimeDaoException;
567
568    //20-3
569    /**
570     * Loads an array of B bean from a template one, given the start row and number of rows.
571     *
572     * @param bean the B bean template to look for
573     * @param startRow the start row to be used (first row = 1, last row=-1)
574     * @param numRows the number of rows to be retrieved (all rows = a negative number)
575     * @param searchType exact ?  like ? starting like ? ending link? <br>
576     *                {@value Constant#SEARCH_EXACT}   {@link Constant#SEARCH_EXACT} <br>
577     *                {@value Constant#SEARCH_LIKE}   {@link Constant#SEARCH_LIKE} <br>
578     *                {@value Constant#SEARCH_STARTING_LIKE}   {@link Constant#SEARCH_STARTING_LIKE} <br>
579     *                {@value Constant#SEARCH_ENDING_LIKE}   {@link Constant#SEARCH_ENDING_LIKE} <br>  
580     * @return all the B beans matching the template
581     * @throws RuntimeDaoException
582     */
583    public List<B> loadUsingTemplateAsList(B bean, int startRow, int numRows, int searchType)throws RuntimeDaoException;
584    //20-4
585    /**
586     * Retrieves each row of B bean given a SQL where clause and a list of fields,
587     * and dealt with each action.
588     * It is up to you to pass the 'WHERE' in your where clauses.
589     * @param each DoForEach object for do something(not null)
590     * @param stopOnError stop on error
591     * @param where the SQL 'where' clause, retrieves all rows if {@code null} or empty
592     * @throws RuntimeDaoException
593     */
594    public void foreachByWhere(DoEach<B> each, boolean stopOnError, String where)throws RuntimeDaoException;
595    //20-5
596    /**
597     * Retrieves each row of B bean given a SQL where clause and a list of fields,
598     * and dealt with each action.
599     * It is up to you to pass the 'WHERE' in your where clauses.
600     * @param each DoForEach object for do something(not null)
601     * @param stopOnError stop on error
602     * @throws RuntimeDaoException
603     */
604    public void foreach(DoEach<B> each, boolean stopOnError)throws RuntimeDaoException;
605    //_____________________________________________________________________
606    //
607    // LISTENER
608    //_____________________________________________________________________
609
610    //35
611    /**
612     * Registers a unique {@link TableListener} listener.<br>
613     * do nothing if {@code TableListener} instance exists
614     * @param listener
615     */
616    public void registerListener(TableListener<B> listener);
617
618    //36
619    /**
620     * remove listener.
621     * @param listener 
622     */
623    public void unregisterListener(TableListener<B> listener);
624
625    //_____________________________________________________________________
626    //
627    // SAVE
628    //_____________________________________________________________________
629    //12
630    /**
631     * Saves the B bean into the database.
632     *
633     * @param bean the B bean to be saved
634     * @return the inserted or updated bean,or null if bean is null
635     * @throws RuntimeDaoException
636     */
637    public B save(B bean)throws RuntimeDaoException;
638
639    //12-1
640        /**
641     * If the specified key is not already exist, add it to database.
642     * This is equivalent to
643     *  <pre> {@code
644     * if (!existsByPrimaryKey(bean))
645     *   return insert(bean);
646     * else
647     *   return loadByPrimaryKey(bean);
648     * }</pre>
649     *
650     * except that the action is performed atomically .
651         * @param bean the B bean to be saved
652     * @return the previous value exists in database, or saved bean if not exists bean ,
653     *                          or {@code null} if bean is {@code null}
654         * @throws RuntimeDaoException
655         */
656        public B addIfAbsent(B bean) throws RuntimeDaoException;
657    //15
658    /**
659     * Saves an array of B bean into the database.
660     *
661     * @param beans the array of  B bean to be saved
662     * @return always beans saved
663     * @throws RuntimeDaoException
664     */
665    public B[] save(B[] beans)throws RuntimeDaoException;
666    
667    //15-2
668    /**
669     * Saves a collection of B bean into the database.
670     *
671     * @param beans the B bean table to be saved
672     * @return alwarys beans saved
673     * @throws RuntimeDaoException
674     */
675    public <C extends Collection<B>> C saveAsTransaction(C beans)throws RuntimeDaoException;
676    
677    //15-3
678    /**
679     * Saves an array of B bean into the database as transaction.
680     *
681     * @param beans the B bean table to be saved
682     * @return alwarys beans saved
683     * @see #save(BaseBean[])
684     * @throws RuntimeDaoException
685     */
686    public B[] saveAsTransaction(B[] beans)throws RuntimeDaoException;
687
688    //15-4
689    /**
690     * Saves a collection of B bean into the database as transaction.
691     *
692     * @param beans the B bean table to be saved
693     * @return alwarys beans saved
694     * @throws RuntimeDaoException
695     */
696    public <C extends Collection<B>> C save(C beans)throws RuntimeDaoException;
697
698    /**
699     * Load column from table.
700     * @param column column name or java file name of B
701     * @param distinct select distinct values
702     * @param where the sql 'where' clause
703     * @param startRow the start row to be used (first row = 1, last row = -1)
704     * @param numRows the number of rows to be retrieved (all rows = a negative number)
705     * @return an list of column
706     * @throws RuntimeDaoException
707     */
708    public <T>List<T> loadColumnAsList(String column,boolean distinct,String where,int startRow,int numRows)throws RuntimeDaoException;
709}