All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.onetwo.common.db.builder.QueryBuilderJoin Maven / Gradle / Ivy

package org.onetwo.common.db.builder;

import java.util.List;

import org.onetwo.common.utils.LangUtils;

public class QueryBuilderJoin {
	
	public static class OnCause {
		
		private QueryBuilderJoin join;
		private String left;
		private String right;
		
		public OnCause(QueryBuilderJoin join, String left, String right) {
			super();
			this.join = join;
			this.left = left;
			this.right = right;
		}
		
		protected String getFieldName(String field){
			if(field.contains("."))
				return field;
			return join.getBuilder().getAlias()+"."+field;
		}

		public String toSql(){
			return LangUtils.append(getFieldName(left), " = ", right);
		}

		public String toString(){
			return toSql();
		}
	}
	
	private QueryBuilder builder;
	private String joinTable;
	private String alias;
	private List onCauses = LangUtils.newArrayList();
	
	public QueryBuilderJoin(QueryBuilder builder, String joinTable, String alias) {
		super();
		this.joinTable = joinTable;
		this.builder = builder;
		this.alias = alias;
	}
	
	
	public QueryBuilder getBuilder() {
		return builder;
	}


	public QueryBuilder on(String...onCause){
		for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy