Java Code Examples for org.hibernate.mapping.Column#getQuotedName()

The following examples show how to use org.hibernate.mapping.Column#getQuotedName() . 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 File: TypeSafeActivator.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static void applyMin(Property property, ConstraintDescriptor<?> descriptor, Dialect dialect) {
	if ( Min.class.equals( descriptor.getAnnotation().annotationType() ) ) {
		@SuppressWarnings("unchecked")
		ConstraintDescriptor<Min> minConstraint = (ConstraintDescriptor<Min>) descriptor;
		long min = minConstraint.getAnnotation().value();

		@SuppressWarnings("unchecked")
		final Iterator<Selectable> itor = property.getColumnIterator();
		if ( itor.hasNext() ) {
			final Selectable selectable = itor.next();
			if ( Column.class.isInstance( selectable ) ) {
				Column col = (Column) selectable;
				String checkConstraint = col.getQuotedName(dialect) + ">=" + min;
				applySQLCheck( col, checkConstraint );
			}
		}
	}
}
 
Example 2
Source File: TypeSafeActivator.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static void applyMax(Property property, ConstraintDescriptor<?> descriptor, Dialect dialect) {
	if ( Max.class.equals( descriptor.getAnnotation().annotationType() ) ) {
		@SuppressWarnings("unchecked")
		ConstraintDescriptor<Max> maxConstraint = (ConstraintDescriptor<Max>) descriptor;
		long max = maxConstraint.getAnnotation().value();

		@SuppressWarnings("unchecked")
		final Iterator<Selectable> itor = property.getColumnIterator();
		if ( itor.hasNext() ) {
			final Selectable selectable = itor.next();
			if ( Column.class.isInstance( selectable ) ) {
				Column col = (Column) selectable;
				String checkConstraint = col.getQuotedName( dialect ) + "<=" + max;
				applySQLCheck( col, checkConstraint );
			}
		}
	}
}
 
Example 3
Source File: Mappings.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void addColumnBinding(String logicalName, Column finalColumn, Table table) {
	ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(table);
	if (binding == null) {
		binding = new ColumnNames();
		columnNameBindingPerTable.put(table, binding);
	}
	String oldFinalName = (String) binding.logicalToPhysical.put(
			logicalName.toLowerCase(),
			finalColumn.getQuotedName()
	);
	if ( oldFinalName != null &&
			! ( finalColumn.isQuoted() ?
					oldFinalName.equals( finalColumn.getQuotedName() ) :
					oldFinalName.equalsIgnoreCase( finalColumn.getQuotedName() ) ) ) {
		//TODO possibly relax that
		throw new MappingException("Same logical column name referenced by different physical ones: "
				+ table.getName() + "." + logicalName + " => '" + oldFinalName + "' and '" + finalColumn.getQuotedName() + "'" );
	}
	String oldLogicalName = (String) binding.physicalToLogical.put(
			finalColumn.getQuotedName(),
			logicalName
	);
	if ( oldLogicalName != null && ! oldLogicalName.equals( logicalName ) ) {
		//TODO possibly relax that
		throw new MappingException("Same physical column represented by different logical column names: "
				+ table.getName() + "." + finalColumn.getQuotedName() + " => '" + oldLogicalName + "' and '" + logicalName + "'");
	}
}
 
Example 4
Source File: SpannerTableStatements.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Converts a {@link Column} into its column + type string; i.e. "col_name string not null"
 */
private String buildColumnTypeString(Column col, Metadata metadata) {
  return col.getQuotedName() + " " + col.getSqlType(this.spannerDialect, metadata)
      + (col.isNullable() ? this.spannerDialect.getNullColumnString() : " not null");
}
 
Example 5
Source File: InFlightMetadataCollectorImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public void addBinding(Identifier logicalName, Column physicalColumn) {
	final String physicalNameString = physicalColumn.getQuotedName( getDatabase().getJdbcEnvironment().getDialect() );

	bindLogicalToPhysical( logicalName, physicalNameString );
	bindPhysicalToLogical( logicalName, physicalNameString );
}