/** * The sequence table name. Defaults to <code>OPENJPA_SEQUENCE_TABLE</code>. * By default, the table will be placed in the first schema listed in your * <code>openjpa.jdbc.Schemas</code> property, or in the default schema if * the property is not given. If you specify a table name in the form * <code><schema>.<table></code>, then the given schema * will be used. */ public void setTable(String name) { // Split the name into its individual parts String[] names = Normalizer.splitName(name); // Join the name back together. This will delimit as appropriate. _table = DBIdentifier.newTable(Normalizer.joinNames(names)); }
/** * The sequence table name. Defaults to <code>OPENJPA_SEQUENCE_TABLE</code>. * By default, the table will be placed in the first schema listed in your * <code>openjpa.jdbc.Schemas</code> property, or in the default schema if * the property is not given. If you specify a table name in the form * <code><schema>.<table></code>, then the given schema * will be used. */ public void setTable(String name) { // Split the name into its individual parts String[] names = Normalizer.splitName(name); // Join the name back together. This will delimit as appropriate. _table = DBIdentifier.newTable(Normalizer.joinNames(names)); }
/** * The sequence table name. Defaults to <code>OPENJPA_SEQUENCE_TABLE</code>. * By default, the table will be placed in the first schema listed in your * <code>openjpa.jdbc.Schemas</code> property, or in the default schema if * the property is not given. If you specify a table name in the form * <code><schema>.<table></code>, then the given schema * will be used. */ public void setTable(String name) { // Split the name into its individual parts String[] names = Normalizer.splitName(name); // Join the name back together. This will delimit as appropriate. _table = DBIdentifier.newTable(Normalizer.joinNames(names)); }
/** * The sequence table name. Defaults to <code>OPENJPA_SEQUENCE_TABLE</code>. * By default, the table will be placed in the first schema listed in your * <code>openjpa.jdbc.Schemas</code> property, or in the default schema if * the property is not given. If you specify a table name in the form * <code><schema>.<table></code>, then the given schema * will be used. */ public void setTable(String name) { // Split the name into its individual parts String[] names = Normalizer.splitName(name); // Join the name back together. This will delimit as appropriate. _table = DBIdentifier.newTable(Normalizer.joinNames(names)); }
public static DBIdentifier getNewTableSchemaIdentifier(JDBCConfiguration conf) { if (conf.getSchema() != null) return DBIdentifier.newSchema(conf.getSchema()); String[] schemas = conf.getSchemasList(); if (schemas.length == 0) return DBIdentifier.NULL; String[] names = Normalizer.splitName(schemas[0]); if (names.length == 0 || StringUtils.isEmpty(names[0])) { return DBIdentifier.NULL; } return DBIdentifier.newSchema(names[0]); }
public static DBIdentifier getNewTableSchemaIdentifier(JDBCConfiguration conf) { if (conf.getSchema() != null) return DBIdentifier.newSchema(conf.getSchema()); String[] schemas = conf.getSchemasList(); if (schemas.length == 0) return DBIdentifier.NULL; String[] names = Normalizer.splitName(schemas[0]); if (names.length == 0 || StringUtils.isEmpty(names[0])) { return DBIdentifier.NULL; } return DBIdentifier.newSchema(names[0]); }
/** * Splits a string delimited by the specified delimiter of a given name type * into an array of DBIdentifier objects. * Example: COL1|"COL 2"|COL3 delim=| --> DBIdentifier[]{ COL1, "COL 2", COL3 } * @param name * @param id * @param delim */ public static DBIdentifier[] split(String name, DBIdentifierType id, String delim) { if (!Normalizer.canSplit(name, delim)) { return new DBIdentifier[] { new DBIdentifier(name, id) }; } String[] names = Normalizer.splitName(name, delim); if (names.length == 0) { return new DBIdentifier[] { }; } DBIdentifier[] sNames = new DBIdentifier[names.length]; for (int i = 0; i < names.length ; i++) { sNames[i] = new DBIdentifier(names[i], id); } return sNames; }
/** * Splits a string delimited by the specified delimiter of a given name type * into an array of DBIdentifier objects. * Example: COL1|"COL 2"|COL3 delim=| --> DBIdentifier[]{ COL1, "COL 2", COL3 } * @param name * @param id * @param delim */ public static DBIdentifier[] split(String name, DBIdentifierType id, String delim) { if (!Normalizer.canSplit(name, delim)) { return new DBIdentifier[] { new DBIdentifier(name, id) }; } String[] names = Normalizer.splitName(name, delim); if (names.length == 0) { return new DBIdentifier[] { }; } DBIdentifier[] sNames = new DBIdentifier[names.length]; for (int i = 0; i < names.length ; i++) { sNames[i] = new DBIdentifier(names[i], id); } return sNames; }
/** * Splits a given DBIdentifier into multiple DBIdentifiers. Uses the base name * type and heuristics to determine the types and placement of the resulting * components. * @param name */ public static DBIdentifier[] split(DBIdentifierType resultType, String name) { String[] names = Normalizer.splitName(name); switch (names.length) { case 2: return getTwoPartIdentifier(names, resultType); case 3: return getThreePartIdentifier(names, resultType); case 4: return getFourPartIdentifier(names, resultType); default: return new DBIdentifier[] { new DBIdentifier(name, resultType) }; } }
protected SQLBuffer getDeleteTargets(Select sel) { SQLBuffer deleteTargets = new SQLBuffer(this); Collection<String> aliases = sel.getTableAliases(); // Assumes aliases are of the form "TABLENAME t0" // or "\"TABLE NAME\" t0" for (Iterator<String> itr = aliases.iterator(); itr.hasNext();) { String tableAlias = itr.next(); String[] names = Normalizer.splitName(tableAlias, IdentifierUtil.SPACE); if (names.length > 1) { if (allowsAliasInBulkClause) { deleteTargets.append(names[1]); } else { deleteTargets.append(toDBName(DBIdentifier.newTable(names[0]))); } } else { deleteTargets.append(toDBName(DBIdentifier.newTable(tableAlias))); } if (itr.hasNext()) deleteTargets.append(", "); } return deleteTargets; }
/** * Splits a given DBIdentifier into multiple DBIdentifiers. Uses the base name * type and heuristics to determine the types and placement of the resulting * components. * @param name */ public static DBIdentifier[] split(DBIdentifierType resultType, String name) { String[] names = Normalizer.splitName(name); switch (names.length) { case 2: return getTwoPartIdentifier(names, resultType); case 3: return getThreePartIdentifier(names, resultType); case 4: return getFourPartIdentifier(names, resultType); default: return new DBIdentifier[] { new DBIdentifier(name, resultType) }; } }
/** * Splits a given DBIdentifier into multiple DBIdentifiers. Uses the base name * type and heuristics to determine the types and placement of the resulting * components. * @param name * @return */ public static DBIdentifier[] split(DBIdentifierType resultType, String name) { String[] names = Normalizer.splitName(name); switch (names.length) { case 2: return getTwoPartIdentifier(names, resultType); case 3: return getThreePartIdentifier(names, resultType); case 4: return getFourPartIdentifier(names, resultType); default: return new DBIdentifier[] { new DBIdentifier(name, resultType) }; } }
/** * Splits a given DBIdentifier into multiple DBIdentifiers. Uses the base name * type and heuristics to determine the types and placement of the resulting * components. * @param name * @return */ public static DBIdentifier[] split(DBIdentifierType resultType, String name) { String[] names = Normalizer.splitName(name); switch (names.length) { case 2: return getTwoPartIdentifier(names, resultType); case 3: return getThreePartIdentifier(names, resultType); case 4: return getFourPartIdentifier(names, resultType); default: return new DBIdentifier[] { new DBIdentifier(name, resultType) }; } }
protected SQLBuffer getDeleteTargets(Select sel) { SQLBuffer deleteTargets = new SQLBuffer(this); Collection<String> aliases = sel.getTableAliases(); // Assumes aliases are of the form "TABLENAME t0" // or "\"TABLE NAME\" t0" for (Iterator<String> itr = aliases.iterator(); itr.hasNext();) { String tableAlias = itr.next(); String[] names = Normalizer.splitName(tableAlias, IdentifierUtil.SPACE); if (names.length > 1) { if (allowsAliasInBulkClause) { deleteTargets.append(names[1]); } else { deleteTargets.append(toDBName(DBIdentifier.newTable(names[0]))); } } else { deleteTargets.append(toDBName(DBIdentifier.newTable(tableAlias))); } if (itr.hasNext()) deleteTargets.append(", "); } return deleteTargets; }
public static DBIdentifier getNewTableSchemaIdentifier(JDBCConfiguration conf) { if (conf.getSchema() != null) return DBIdentifier.newSchema(conf.getSchema()); String[] schemas = conf.getSchemasList(); if (schemas.length == 0) return DBIdentifier.NULL; String[] names = Normalizer.splitName(schemas[0]); if (names.length == 0 || StringUtil.isEmpty(names[0])) { return DBIdentifier.NULL; } return DBIdentifier.newSchema(names[0]); }
public static DBIdentifier getNewTableSchemaIdentifier(JDBCConfiguration conf) { if (conf.getSchema() != null) return DBIdentifier.newSchema(conf.getSchema()); String[] schemas = conf.getSchemasList(); if (schemas.length == 0) return DBIdentifier.NULL; String[] names = Normalizer.splitName(schemas[0]); if (names.length == 0 || StringUtil.isEmpty(names[0])) { return DBIdentifier.NULL; } return DBIdentifier.newSchema(names[0]); }
/** * Converts a column alias to use the appropriate delimiters */ public String convertAlias(String alias) { if (!needsConversion(getIdentifierConfiguration())) { return alias; } String[] names = Normalizer.splitName(alias); if (names.length <= 1) { // Nothing to split return alias; } // Skip the the first name. It is the alias (T0, T1, etc.) for (int i = 1; i < names.length; i++) { names[i] = toDBName(getIdentifierConfiguration().getDefaultIdentifierRule().toString(), names[i], true); } return joinNames(getIdentifierConfiguration().getDefaultIdentifierRule(), names); }
/** * Converts a column alias to use the appropriate delimiters */ public String convertAlias(String alias) { if (!needsConversion(getIdentifierConfiguration())) { return alias; } String[] names = Normalizer.splitName(alias); if (names.length <= 1) { // Nothing to split return alias; } // Skip the the first name. It is the alias (T0, T1, etc.) for (int i = 1; i < names.length; i++) { names[i] = toDBName(getIdentifierConfiguration().getDefaultIdentifierRule().toString(), names[i], true); } return joinNames(getIdentifierConfiguration().getDefaultIdentifierRule(), names); }
/** * Converts a column alias to use the appropriate delimiters */ public String convertAlias(String alias) { if (!needsConversion(getIdentifierConfiguration())) { return alias; } String[] names = Normalizer.splitName(alias); if (names.length <= 1) { // Nothing to split return alias; } // Skip the the first name. It is the alias (T0, T1, etc.) for (int i = 1; i < names.length; i++) { names[i] = toDBName(getIdentifierConfiguration().getDefaultIdentifierRule().toString(), names[i], true); } return joinNames(getIdentifierConfiguration().getDefaultIdentifierRule(), names); }
/** * Converts a column alias to use the appropriate delimiters */ public String convertAlias(String alias) { if (!needsConversion(getIdentifierConfiguration())) { return alias; } String[] names = Normalizer.splitName(alias); if (names.length <= 1) { // Nothing to split return alias; } // Skip the the first name. It is the alias (T0, T1, etc.) for (int i = 1; i < names.length; i++) { names[i] = toDBName(getIdentifierConfiguration().getDefaultIdentifierRule().toString(), names[i], true); } return joinNames(getIdentifierConfiguration().getDefaultIdentifierRule(), names); }