1 package org.hibernate.hql; 3 4 import org.hibernate.MappingException; 5 import org.hibernate.engine.SessionFactoryImplementor; 6 import org.hibernate.type.Type; 7 8 13 public final class NameGenerator { 14 17 private NameGenerator() { 18 } 19 20 public static String [][] generateColumnNames(Type[] types, SessionFactoryImplementor f) throws MappingException { 21 String [][] columnNames = new String [types.length][]; 22 for ( int i = 0; i < types.length; i++ ) { 23 int span = types[i].getColumnSpan( f ); 24 columnNames[i] = new String [span]; 25 for ( int j = 0; j < span; j++ ) { 26 columnNames[i][j] = NameGenerator.scalarName( i, j ); 27 } 28 } 29 return columnNames; 30 } 31 32 public static String scalarName(int x, int y) { 33 return new StringBuffer () 34 .append( "col_" ) 35 .append( x ) 36 .append( '_' ) 37 .append( y ) 38 .append( '_' ) 39 .toString(); 40 } 41 } 42 | Popular Tags |