Java Code Examples for org.hibernate.annotations.common.util.StringHelper
The following examples show how to use
org.hibernate.annotations.common.util.StringHelper. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: youkefu Source File: UKTableMetaData.java License: Apache License 2.0 | 6 votes |
/** * * @param meta * @throws SQLException */ private void initColumns(DatabaseMetaData meta , boolean upcase) throws SQLException { ResultSet rs = null; try { if (meta.storesUpperCaseIdentifiers()) { rs = meta.getColumns(StringHelper.toUpperCase(catalog), StringHelper.toUpperCase(schema), StringHelper .toUpperCase(name), "%"); } else if (meta.storesLowerCaseIdentifiers()) { rs = meta.getColumns(StringHelper.toLowerCase(catalog), StringHelper.toLowerCase(schema), StringHelper .toLowerCase(name), "%"); } else { rs = meta.getColumns(catalog, schema, name, "%"); } while (rs.next()) addColumn(rs , upcase); }catch(Exception ex){ ex.printStackTrace(); }finally { if (rs != null) rs.close(); } }
Example 2
Source Project: lams Source File: InFlightMetadataCollectorImpl.java License: GNU General Public License v2.0 | 6 votes |
@Override public void addTypeDefinition(TypeDefinition typeDefinition) { if ( typeDefinition == null ) { throw new IllegalArgumentException( "Type definition is null" ); } // Need to register both by name and registration keys. if ( !StringHelper.isEmpty( typeDefinition.getName() ) ) { addTypeDefinition( typeDefinition.getName(), typeDefinition ); } if ( typeDefinition.getRegistrationKeys() != null ) { for ( String registrationKey : typeDefinition.getRegistrationKeys() ) { addTypeDefinition( registrationKey, typeDefinition ); } } }
Example 3
Source Project: lams Source File: Constraint.java License: GNU General Public License v2.0 | 5 votes |
public String sqlCreateString(Dialect dialect, Mapping p, String defaultCatalog, String defaultSchema) { if ( isGenerated( dialect ) ) { // Certain dialects (ex: HANA) don't support FKs as expected, but other constraints can still be created. // If that's the case, hasAlterTable() will be true, but getAddForeignKeyConstraintString will return // empty string. Prevent blank "alter table" statements. String constraintString = sqlConstraintString( dialect, getName(), defaultCatalog, defaultSchema ); if ( !StringHelper.isEmpty( constraintString ) ) { final String tableName = getTable().getQualifiedName( dialect, defaultCatalog, defaultSchema ); return dialect.getAlterTableString( tableName ) + " " + constraintString; } } return null; }
Example 4
Source Project: lams Source File: DialectFactoryImpl.java License: GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("SimplifiableIfStatement") private boolean isEmpty(Object dialectReference) { if ( dialectReference != null ) { // the referenced value is not null if ( dialectReference instanceof String ) { // if it is a String, it might still be empty though... return StringHelper.isEmpty( (String) dialectReference ); } return false; } return true; }
Example 5
Source Project: lams Source File: SessionFactoryRegistry.java License: GNU General Public License v2.0 | 5 votes |
public SessionFactory findSessionFactory(String uuid, String name) { SessionFactory sessionFactory = getSessionFactory( uuid ); if ( sessionFactory == null && StringHelper.isNotEmpty( name ) ) { sessionFactory = getNamedSessionFactory( name ); } return sessionFactory; }
Example 6
Source Project: webdsl Source File: WebDSLDateBridge.java License: Apache License 2.0 | 5 votes |
public Object stringToObject(String stringValue) { if ( StringHelper.isEmpty( stringValue ) ) return null; try { return DateTools.stringToDate( stringValue ); } catch (ParseException e) { throw new SearchException( "Unable to parse into date: " + stringValue, e ); } }
Example 7
Source Project: youkefu Source File: UKDatabaseMetadata.java License: Apache License 2.0 | 4 votes |
/** * * @param name * @param schema * @param catalog * @param isQuoted * @return * @throws Exception */ public List<UKTableMetaData> loadTables(String name, String schema, String catalog, boolean isQuoted) throws Exception { boolean upcase = false ; try { if(properties!=null && properties.get("schema")!=null && schema==null){ schema = properties.get("upcase")!=null?((String)properties.get("schema")).toUpperCase():(String)properties.get("schema") ; } if(properties!=null && properties.get("upcase")!=null){ upcase = properties.get("upcase")!=null && properties.get("upcase").toString().toLowerCase().equals("true"); } UKTableMetaData table = null; Statement statement = null; ResultSet rs = null ; try { if ((isQuoted && meta.storesMixedCaseQuotedIdentifiers())) { rs = meta.getTables(catalog, schema, name, TYPES); } else if ((isQuoted && meta.storesUpperCaseIdentifiers() && meta.storesUpperCaseQuotedIdentifiers()) || (!isQuoted && meta.storesUpperCaseIdentifiers())) { rs = meta.getTables(StringHelper.toUpperCase(catalog), StringHelper.toUpperCase(schema), StringHelper .toUpperCase(name), TYPES); } else if ((isQuoted && meta.storesLowerCaseQuotedIdentifiers()) || (!isQuoted && meta.storesLowerCaseIdentifiers())) { rs = meta.getTables(StringHelper.toLowerCase(catalog), StringHelper.toLowerCase(schema), StringHelper .toLowerCase(name), TYPES); }else if(schema!=null && schema.equals("hive")){ statement = this.connection.createStatement() ; if(properties.get("database")!=null){ statement.execute("USE "+properties.get("database")) ; } rs = statement.executeQuery("SHOW TABLES") ; } else { rs = meta.getTables(catalog, schema, name, TYPES); } while (rs.next()) { String tableName = null ; if(schema!=null && schema.equals("hive")){ tableName = rs.getString("tab_name") ; }else{ tableName = rs.getString("TABLE_NAME"); } if(tableName.matches("[\\da-zA-Z_-\u4e00-\u9fa5]+")){ table = new UKTableMetaData(rs, meta, true , upcase , false , schema); tables.add(table); } } }catch(Exception ex){ ex.printStackTrace(); } finally { if (rs != null){ rs.close(); } if(statement!=null){ statement.close(); } } } catch (SQLException sqle) { throw sqle; } return tables ; }
Example 8
Source Project: youkefu Source File: UKDatabaseMetadata.java License: Apache License 2.0 | 4 votes |
/** * * @param name * @param schema * @param catalog * @param isQuoted * @return * @throws Exception */ public UKTableMetaData loadTable(String name, String schema, String catalog, boolean isQuoted) throws Exception { UKTableMetaData table = null; boolean upcase = false ; try { if(properties!=null && properties.get("schema")!=null && schema==null){ schema = (String)properties.get("schema") ; } if(properties!=null && properties.get("upcase")!=null){ upcase = properties.get("upcase")!=null && properties.get("upcase").toString().toLowerCase().equals("true"); } ResultSet rs = null; try { if ((isQuoted && meta.storesMixedCaseQuotedIdentifiers())) { rs = meta.getTables(catalog, schema, name, TYPES); } else if ((isQuoted && meta.storesUpperCaseQuotedIdentifiers()) || (!isQuoted && meta.storesUpperCaseIdentifiers())) { rs = meta.getTables(StringHelper.toUpperCase(catalog), StringHelper.toUpperCase(schema), StringHelper .toUpperCase(name), TYPES); } else if ((isQuoted && meta.storesLowerCaseQuotedIdentifiers()) || (!isQuoted && meta.storesLowerCaseIdentifiers())) { rs = meta.getTables(StringHelper.toLowerCase(catalog), StringHelper.toLowerCase(schema), StringHelper .toLowerCase(name), TYPES); } else { rs = meta.getTables(catalog, schema, name, TYPES); } while (rs.next()) { table = new UKTableMetaData(rs, meta, true , upcase , true , schema); break ; } } finally { if (rs != null) rs.close(); } } catch (SQLException sqle) { sqle.printStackTrace() ; throw sqle; } return table ; }
Example 9
Source Project: mojito Source File: VarGenerator.java License: Apache License 2.0 | 4 votes |
public static String gen(String description) { return StringHelper.generateAlias(description.replaceAll("\\(|\\)", ""), nextValue()); }