1 package org.hibernate.sql; 3 4 import org.hibernate.util.StringHelper; 5 6 11 public abstract class JoinFragment { 12 13 public abstract void addJoin(String tableName, String alias, String [] fkColumns, String [] pkColumns, int joinType); 14 15 public abstract void addJoin(String tableName, String alias, String [] fkColumns, String [] pkColumns, int joinType, String on); 16 17 public abstract void addCrossJoin(String tableName, String alias); 18 19 public abstract void addJoins(String fromFragment, String whereFragment); 20 21 public abstract String toFromFragmentString(); 22 23 public abstract String toWhereFragmentString(); 24 25 public abstract void addCondition(String alias, String [] fkColumns, String [] pkColumns); 27 28 public abstract boolean addCondition(String condition); 29 31 public abstract JoinFragment copy(); 32 33 public static final int INNER_JOIN = 0; 34 public static final int FULL_JOIN = 4; 35 public static final int LEFT_OUTER_JOIN = 1; 36 public static final int RIGHT_OUTER_JOIN = 2; 37 38 private boolean hasFilterCondition = false; 39 private boolean hasThetaJoins = false; 40 41 public void addFragment(JoinFragment ojf) { 42 if ( ojf.hasThetaJoins() ) { 43 hasThetaJoins = true; 44 } 45 addJoins( ojf.toFromFragmentString(), ojf.toWhereFragmentString() ); 46 } 47 48 56 protected boolean addCondition(StringBuffer buffer, String on) { 57 if ( StringHelper.isNotEmpty( on ) ) { 58 if ( !on.startsWith( " and" ) ) buffer.append( " and " ); 59 buffer.append( on ); 60 return true; 61 } 62 else { 63 return false; 64 } 65 } 66 67 72 public boolean hasFilterCondition() { 73 return hasFilterCondition; 74 } 75 76 public void setHasFilterCondition(boolean b) { 77 this.hasFilterCondition = b; 78 } 79 80 public boolean hasThetaJoins() { 81 return hasThetaJoins; 82 } 83 84 public void setHasThetaJoins(boolean hasThetaJoins) { 85 this.hasThetaJoins = hasThetaJoins; 86 } 87 } 88 | Popular Tags |