1 package org.hibernate.mapping; 3 4 import java.io.Serializable ; 5 6 import org.hibernate.dialect.Dialect; 7 import org.hibernate.sql.Template; 8 9 13 public class Formula implements Selectable, Serializable { 14 private static int formulaUniqueInteger=0; 15 16 private String formula; 17 private int uniqueInteger; 18 19 public Formula() { 20 uniqueInteger = formulaUniqueInteger++; 21 } 22 23 public String getTemplate(Dialect dialect) { 24 return Template.renderWhereStringTemplate(formula, dialect); 25 } 26 public String getText(Dialect dialect) { 27 return getFormula(); 28 } 29 public String getText() { 30 return getFormula(); 31 } 32 public String getAlias(Dialect dialect) { 33 return "formula" + Integer.toString(uniqueInteger) + '_'; 34 } 35 public String getAlias(Dialect dialect, Table table) { 36 return getAlias(dialect); 37 } 38 public String getFormula() { 39 return formula; 40 } 41 public void setFormula(String string) { 42 formula = string; 43 } 44 public boolean isFormula() { 45 return true; 46 } 47 48 public String toString() { 49 return this.getClass().getName() + "( " + formula + " )"; 50 } 51 } 52 | Popular Tags |