KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > loader > collection > CollectionJoinWalker


1 //$Id: CollectionJoinWalker.java,v 1.2 2005/06/13 20:27:16 oneovthafew Exp $
2
package org.hibernate.loader.collection;
3
4 import java.util.Map JavaDoc;
5
6 import org.hibernate.engine.SessionFactoryImplementor;
7 import org.hibernate.loader.JoinWalker;
8 import org.hibernate.util.StringHelper;
9
10 /**
11  * Superclass of walkers for collection initializers
12  *
13  * @see CollectionLoader
14  * @see OneToManyJoinWalker
15  * @see BasicCollectionJoinWalker
16  * @author Gavin King
17  */

18 public abstract class CollectionJoinWalker extends JoinWalker {
19     
20     private final String JavaDoc subselect;
21
22     public CollectionJoinWalker(String JavaDoc subselect, SessionFactoryImplementor factory, Map JavaDoc enabledFilters) {
23         super( factory, enabledFilters );
24         this.subselect = subselect;
25     }
26
27     protected StringBuffer JavaDoc whereString(String JavaDoc alias, String JavaDoc[] columnNames, int batchSize) {
28         if (subselect==null) {
29             return super.whereString(alias, columnNames, batchSize);
30         }
31         else {
32             StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
33             if (columnNames.length>1) buf.append('(');
34             buf.append( StringHelper.join(", ", StringHelper.qualify(alias, columnNames) ) );
35             if (columnNames.length>1) buf.append(')');
36             buf.append(" in ")
37                 .append('(')
38                 .append(subselect)
39                 .append(')');
40             return buf;
41         }
42     }
43 }
44
Popular Tags