HHH-6386 sybase improvement

This commit is contained in:
Strong Liu 2011-07-05 12:32:42 +08:00
parent 793f317ea9
commit e8b682b405
11 changed files with 195 additions and 177 deletions

View File

@ -214,7 +214,7 @@ sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE FROM CATS").addEntity(Cat.class)
<para>The following form is not vulnerable to column name <para>The following form is not vulnerable to column name
duplication:</para> duplication:</para>
<programlisting role="JAVA">sess.createSQLQuery("SELECT {cat.*}, {mother.*} FROM CATS c, CATS m WHERE c.MOTHER_ID = c.ID") <programlisting role="JAVA">sess.createSQLQuery("SELECT {cat.*}, {m.*} FROM CATS c, CATS m WHERE c.MOTHER_ID = m.ID")
.addEntity("cat", Cat.class) .addEntity("cat", Cat.class)
.addEntity("mother", Cat.class) .addEntity("mother", Cat.class)
</programlisting> </programlisting>

View File

@ -24,6 +24,7 @@
package org.hibernate.dialect; package org.hibernate.dialect;
import java.sql.Types; import java.sql.Types;
import org.hibernate.dialect.function.AnsiTrimEmulationFunction; import org.hibernate.dialect.function.AnsiTrimEmulationFunction;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
@ -40,7 +41,9 @@ public class SybaseASE15Dialect extends AbstractTransactSQLDialect {
registerColumnType( Types.LONGVARBINARY, "image" ); registerColumnType( Types.LONGVARBINARY, "image" );
registerColumnType( Types.LONGVARCHAR, "text" ); registerColumnType( Types.LONGVARCHAR, "text" );
registerColumnType(Types.BINARY, "binary($l)");
registerColumnType(Types.REAL, "real");
registerColumnType(Types.BOOLEAN, "bit");
registerFunction( "second", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart(second, ?1)") ); registerFunction( "second", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart(second, ?1)") );
registerFunction( "minute", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "datepart(minute, ?1)") ); registerFunction( "minute", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "datepart(minute, ?1)") );
registerFunction( "hour", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "datepart(hour, ?1)") ); registerFunction( "hour", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "datepart(hour, ?1)") );
@ -48,6 +51,8 @@ public class SybaseASE15Dialect extends AbstractTransactSQLDialect {
registerFunction( "mod", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "?1 % ?2" ) ); registerFunction( "mod", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "?1 % ?2" ) );
registerFunction( "bit_length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datalength(?1) * 8" ) ); registerFunction( "bit_length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datalength(?1) * 8" ) );
registerFunction( "trim", new AnsiTrimEmulationFunction( AnsiTrimEmulationFunction.LTRIM, AnsiTrimEmulationFunction.RTRIM, "str_replace" ) ); registerFunction( "trim", new AnsiTrimEmulationFunction( AnsiTrimEmulationFunction.LTRIM, AnsiTrimEmulationFunction.RTRIM, "str_replace" ) );
registerFunction( "sysdate", new NoArgSQLFunction("getdate", StandardBasicTypes.TIMESTAMP) );
} }
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -78,6 +83,12 @@ public class SybaseASE15Dialect extends AbstractTransactSQLDialect {
public boolean supportsExpectedLobUsagePattern() { public boolean supportsExpectedLobUsagePattern() {
return false; return false;
} }
@Override
public boolean supportsUniqueConstraintInCreateAlterTable() {
return false;
}
public String getCrossJoinSeparator() { public String getCrossJoinSeparator() {
return ", "; return ", ";
} }

View File

@ -87,7 +87,6 @@ public class ForeignKey extends Constraint {
* Validates that columnspan of the foreignkey and the primarykey is the same. * Validates that columnspan of the foreignkey and the primarykey is the same.
* *
* Furthermore it aligns the length of the underlying tables columns. * Furthermore it aligns the length of the underlying tables columns.
* @param referencedTable
*/ */
public void alignColumns() { public void alignColumns() {
if ( isReferenceToPrimaryKey() ) alignColumns(referencedTable); if ( isReferenceToPrimaryKey() ) alignColumns(referencedTable);

View File

@ -106,80 +106,80 @@ import org.hibernate.annotations.WhereJoinTable;
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
public interface HibernateDotNames { public interface HibernateDotNames {
public static final DotName ACCESS_TYPE = DotName.createSimple( AccessType.class.getName() ); DotName ACCESS_TYPE = DotName.createSimple( AccessType.class.getName() );
public static final DotName ANY = DotName.createSimple( Any.class.getName() ); DotName ANY = DotName.createSimple( Any.class.getName() );
public static final DotName ANY_META_DEF = DotName.createSimple( AnyMetaDef.class.getName() ); DotName ANY_META_DEF = DotName.createSimple( AnyMetaDef.class.getName() );
public static final DotName ANY_META_DEFS = DotName.createSimple( AnyMetaDefs.class.getName() ); DotName ANY_META_DEFS = DotName.createSimple( AnyMetaDefs.class.getName() );
public static final DotName BATCH_SIZE = DotName.createSimple( BatchSize.class.getName() ); DotName BATCH_SIZE = DotName.createSimple( BatchSize.class.getName() );
public static final DotName CACHE = DotName.createSimple( Cache.class.getName() ); DotName CACHE = DotName.createSimple( Cache.class.getName() );
public static final DotName CASCADE = DotName.createSimple( Cascade.class.getName() ); DotName CASCADE = DotName.createSimple( Cascade.class.getName() );
public static final DotName CHECK = DotName.createSimple( Check.class.getName() ); DotName CHECK = DotName.createSimple( Check.class.getName() );
public static final DotName COLLECTION_ID = DotName.createSimple( CollectionId.class.getName() ); DotName COLLECTION_ID = DotName.createSimple( CollectionId.class.getName() );
public static final DotName COLUMNS = DotName.createSimple( Columns.class.getName() ); DotName COLUMNS = DotName.createSimple( Columns.class.getName() );
public static final DotName COLUMN_TRANSFORMER = DotName.createSimple( ColumnTransformer.class.getName() ); DotName COLUMN_TRANSFORMER = DotName.createSimple( ColumnTransformer.class.getName() );
public static final DotName COLUMN_TRANSFORMERS = DotName.createSimple( ColumnTransformers.class.getName() ); DotName COLUMN_TRANSFORMERS = DotName.createSimple( ColumnTransformers.class.getName() );
public static final DotName DISCRIMINATOR_FORMULA = DotName.createSimple( DiscriminatorFormula.class.getName() ); DotName DISCRIMINATOR_FORMULA = DotName.createSimple( DiscriminatorFormula.class.getName() );
public static final DotName DISCRIMINATOR_OPTIONS = DotName.createSimple( DiscriminatorOptions.class.getName() ); DotName DISCRIMINATOR_OPTIONS = DotName.createSimple( DiscriminatorOptions.class.getName() );
public static final DotName ENTITY = DotName.createSimple( Entity.class.getName() ); DotName ENTITY = DotName.createSimple( Entity.class.getName() );
public static final DotName FETCH = DotName.createSimple( Fetch.class.getName() ); DotName FETCH = DotName.createSimple( Fetch.class.getName() );
public static final DotName FETCH_PROFILE = DotName.createSimple( FetchProfile.class.getName() ); DotName FETCH_PROFILE = DotName.createSimple( FetchProfile.class.getName() );
public static final DotName FETCH_PROFILES = DotName.createSimple( FetchProfiles.class.getName() ); DotName FETCH_PROFILES = DotName.createSimple( FetchProfiles.class.getName() );
public static final DotName FILTER = DotName.createSimple( Filter.class.getName() ); DotName FILTER = DotName.createSimple( Filter.class.getName() );
public static final DotName FILTER_DEF = DotName.createSimple( FilterDef.class.getName() ); DotName FILTER_DEF = DotName.createSimple( FilterDef.class.getName() );
public static final DotName FILTER_DEFS = DotName.createSimple( FilterDefs.class.getName() ); DotName FILTER_DEFS = DotName.createSimple( FilterDefs.class.getName() );
public static final DotName FILTER_JOIN_TABLE = DotName.createSimple( FilterJoinTable.class.getName() ); DotName FILTER_JOIN_TABLE = DotName.createSimple( FilterJoinTable.class.getName() );
public static final DotName FILTER_JOIN_TABLES = DotName.createSimple( FilterJoinTables.class.getName() ); DotName FILTER_JOIN_TABLES = DotName.createSimple( FilterJoinTables.class.getName() );
public static final DotName FILTERS = DotName.createSimple( Filters.class.getName() ); DotName FILTERS = DotName.createSimple( Filters.class.getName() );
public static final DotName FOREIGN_KEY = DotName.createSimple( ForeignKey.class.getName() ); DotName FOREIGN_KEY = DotName.createSimple( ForeignKey.class.getName() );
public static final DotName FORMULA = DotName.createSimple( Formula.class.getName() ); DotName FORMULA = DotName.createSimple( Formula.class.getName() );
public static final DotName GENERATED = DotName.createSimple( Generated.class.getName() ); DotName GENERATED = DotName.createSimple( Generated.class.getName() );
public static final DotName GENERIC_GENERATOR = DotName.createSimple( GenericGenerator.class.getName() ); DotName GENERIC_GENERATOR = DotName.createSimple( GenericGenerator.class.getName() );
public static final DotName GENERIC_GENERATORS = DotName.createSimple( GenericGenerators.class.getName() ); DotName GENERIC_GENERATORS = DotName.createSimple( GenericGenerators.class.getName() );
public static final DotName IMMUTABLE = DotName.createSimple( Immutable.class.getName() ); DotName IMMUTABLE = DotName.createSimple( Immutable.class.getName() );
public static final DotName INDEX = DotName.createSimple( Index.class.getName() ); DotName INDEX = DotName.createSimple( Index.class.getName() );
public static final DotName INDEX_COLUMN = DotName.createSimple( IndexColumn.class.getName() ); DotName INDEX_COLUMN = DotName.createSimple( IndexColumn.class.getName() );
public static final DotName JOIN_COLUMN_OR_FORMULA = DotName.createSimple( JoinColumnOrFormula.class.getName() ); DotName JOIN_COLUMN_OR_FORMULA = DotName.createSimple( JoinColumnOrFormula.class.getName() );
public static final DotName JOIN_COLUMNS_OR_FORMULAS = DotName.createSimple( JoinColumnsOrFormulas.class.getName() ); DotName JOIN_COLUMNS_OR_FORMULAS = DotName.createSimple( JoinColumnsOrFormulas.class.getName() );
public static final DotName JOIN_FORMULA = DotName.createSimple( JoinFormula.class.getName() ); DotName JOIN_FORMULA = DotName.createSimple( JoinFormula.class.getName() );
public static final DotName LAZY_COLLECTION = DotName.createSimple( LazyCollection.class.getName() ); DotName LAZY_COLLECTION = DotName.createSimple( LazyCollection.class.getName() );
public static final DotName LAZY_TO_ONE = DotName.createSimple( LazyToOne.class.getName() ); DotName LAZY_TO_ONE = DotName.createSimple( LazyToOne.class.getName() );
public static final DotName LOADER = DotName.createSimple( Loader.class.getName() ); DotName LOADER = DotName.createSimple( Loader.class.getName() );
public static final DotName MANY_TO_ANY = DotName.createSimple( ManyToAny.class.getName() ); DotName MANY_TO_ANY = DotName.createSimple( ManyToAny.class.getName() );
public static final DotName MAP_KEY_TYPE = DotName.createSimple( MapKeyType.class.getName() ); DotName MAP_KEY_TYPE = DotName.createSimple( MapKeyType.class.getName() );
public static final DotName META_VALUE = DotName.createSimple( MetaValue.class.getName() ); DotName META_VALUE = DotName.createSimple( MetaValue.class.getName() );
public static final DotName NAMED_NATIVE_QUERIES = DotName.createSimple( NamedNativeQueries.class.getName() ); DotName NAMED_NATIVE_QUERIES = DotName.createSimple( NamedNativeQueries.class.getName() );
public static final DotName NAMED_NATIVE_QUERY = DotName.createSimple( NamedNativeQuery.class.getName() ); DotName NAMED_NATIVE_QUERY = DotName.createSimple( NamedNativeQuery.class.getName() );
public static final DotName NAMED_QUERIES = DotName.createSimple( NamedQueries.class.getName() ); DotName NAMED_QUERIES = DotName.createSimple( NamedQueries.class.getName() );
public static final DotName NAMED_QUERY = DotName.createSimple( NamedQuery.class.getName() ); DotName NAMED_QUERY = DotName.createSimple( NamedQuery.class.getName() );
public static final DotName NATURAL_ID = DotName.createSimple( NaturalId.class.getName() ); DotName NATURAL_ID = DotName.createSimple( NaturalId.class.getName() );
public static final DotName NOT_FOUND = DotName.createSimple( NotFound.class.getName() ); DotName NOT_FOUND = DotName.createSimple( NotFound.class.getName() );
public static final DotName ON_DELETE = DotName.createSimple( OnDelete.class.getName() ); DotName ON_DELETE = DotName.createSimple( OnDelete.class.getName() );
public static final DotName OPTIMISTIC_LOCK = DotName.createSimple( OptimisticLock.class.getName() ); DotName OPTIMISTIC_LOCK = DotName.createSimple( OptimisticLock.class.getName() );
public static final DotName ORDER_BY = DotName.createSimple( OrderBy.class.getName() ); DotName ORDER_BY = DotName.createSimple( OrderBy.class.getName() );
public static final DotName PARAM_DEF = DotName.createSimple( ParamDef.class.getName() ); DotName PARAM_DEF = DotName.createSimple( ParamDef.class.getName() );
public static final DotName PARAMETER = DotName.createSimple( Parameter.class.getName() ); DotName PARAMETER = DotName.createSimple( Parameter.class.getName() );
public static final DotName PARENT = DotName.createSimple( Parent.class.getName() ); DotName PARENT = DotName.createSimple( Parent.class.getName() );
public static final DotName PERSISTER = DotName.createSimple( Persister.class.getName() ); DotName PERSISTER = DotName.createSimple( Persister.class.getName() );
public static final DotName PROXY = DotName.createSimple( Proxy.class.getName() ); DotName PROXY = DotName.createSimple( Proxy.class.getName() );
public static final DotName ROW_ID = DotName.createSimple( RowId.class.getName() ); DotName ROW_ID = DotName.createSimple( RowId.class.getName() );
public static final DotName SORT = DotName.createSimple( Sort.class.getName() ); DotName SORT = DotName.createSimple( Sort.class.getName() );
public static final DotName SOURCE = DotName.createSimple( Source.class.getName() ); DotName SOURCE = DotName.createSimple( Source.class.getName() );
public static final DotName SQL_DELETE = DotName.createSimple( SQLDelete.class.getName() ); DotName SQL_DELETE = DotName.createSimple( SQLDelete.class.getName() );
public static final DotName SQL_DELETE_ALL = DotName.createSimple( SQLDeleteAll.class.getName() ); DotName SQL_DELETE_ALL = DotName.createSimple( SQLDeleteAll.class.getName() );
public static final DotName SQL_INSERT = DotName.createSimple( SQLInsert.class.getName() ); DotName SQL_INSERT = DotName.createSimple( SQLInsert.class.getName() );
public static final DotName SQL_UPDATE = DotName.createSimple( SQLUpdate.class.getName() ); DotName SQL_UPDATE = DotName.createSimple( SQLUpdate.class.getName() );
public static final DotName SUB_SELECT = DotName.createSimple( Subselect.class.getName() ); DotName SUB_SELECT = DotName.createSimple( Subselect.class.getName() );
public static final DotName SYNCHRONIZE = DotName.createSimple( Synchronize.class.getName() ); DotName SYNCHRONIZE = DotName.createSimple( Synchronize.class.getName() );
public static final DotName TABLE = DotName.createSimple( Table.class.getName() ); DotName TABLE = DotName.createSimple( Table.class.getName() );
public static final DotName TABLES = DotName.createSimple( Tables.class.getName() ); DotName TABLES = DotName.createSimple( Tables.class.getName() );
public static final DotName TARGET = DotName.createSimple( Target.class.getName() ); DotName TARGET = DotName.createSimple( Target.class.getName() );
public static final DotName TUPLIZER = DotName.createSimple( Tuplizer.class.getName() ); DotName TUPLIZER = DotName.createSimple( Tuplizer.class.getName() );
public static final DotName TUPLIZERS = DotName.createSimple( Tuplizers.class.getName() ); DotName TUPLIZERS = DotName.createSimple( Tuplizers.class.getName() );
public static final DotName TYPE = DotName.createSimple( Type.class.getName() ); DotName TYPE = DotName.createSimple( Type.class.getName() );
public static final DotName TYPE_DEF = DotName.createSimple( TypeDef.class.getName() ); DotName TYPE_DEF = DotName.createSimple( TypeDef.class.getName() );
public static final DotName TYPE_DEFS = DotName.createSimple( TypeDefs.class.getName() ); DotName TYPE_DEFS = DotName.createSimple( TypeDefs.class.getName() );
public static final DotName WHERE = DotName.createSimple( Where.class.getName() ); DotName WHERE = DotName.createSimple( Where.class.getName() );
public static final DotName WHERE_JOIN_TABLE = DotName.createSimple( WhereJoinTable.class.getName() ); DotName WHERE_JOIN_TABLE = DotName.createSimple( WhereJoinTable.class.getName() );
} }

View File

@ -117,91 +117,91 @@ import org.jboss.jandex.DotName;
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
public interface JPADotNames { public interface JPADotNames {
public static final DotName ACCESS = DotName.createSimple( Access.class.getName() ); DotName ACCESS = DotName.createSimple( Access.class.getName() );
public static final DotName ACCESS_TYPE = DotName.createSimple( AccessType.class.getName() ); DotName ACCESS_TYPE = DotName.createSimple( AccessType.class.getName() );
public static final DotName ASSOCIATION_OVERRIDE = DotName.createSimple( AssociationOverride.class.getName() ); DotName ASSOCIATION_OVERRIDE = DotName.createSimple( AssociationOverride.class.getName() );
public static final DotName ASSOCIATION_OVERRIDES = DotName.createSimple( AssociationOverrides.class.getName() ); DotName ASSOCIATION_OVERRIDES = DotName.createSimple( AssociationOverrides.class.getName() );
public static final DotName ATTRIBUTE_OVERRIDE = DotName.createSimple( AttributeOverride.class.getName() ); DotName ATTRIBUTE_OVERRIDE = DotName.createSimple( AttributeOverride.class.getName() );
public static final DotName ATTRIBUTE_OVERRIDES = DotName.createSimple( AttributeOverrides.class.getName() ); DotName ATTRIBUTE_OVERRIDES = DotName.createSimple( AttributeOverrides.class.getName() );
public static final DotName BASIC = DotName.createSimple( Basic.class.getName() ); DotName BASIC = DotName.createSimple( Basic.class.getName() );
public static final DotName CACHEABLE = DotName.createSimple( Cacheable.class.getName() ); DotName CACHEABLE = DotName.createSimple( Cacheable.class.getName() );
public static final DotName CASCADE_TYPE = DotName.createSimple( CascadeType.class.getName() ); DotName CASCADE_TYPE = DotName.createSimple( CascadeType.class.getName() );
public static final DotName COLLECTION_TABLE = DotName.createSimple( CollectionTable.class.getName() ); DotName COLLECTION_TABLE = DotName.createSimple( CollectionTable.class.getName() );
public static final DotName COLUMN = DotName.createSimple( Column.class.getName() ); DotName COLUMN = DotName.createSimple( Column.class.getName() );
public static final DotName COLUMN_RESULT = DotName.createSimple( ColumnResult.class.getName() ); DotName COLUMN_RESULT = DotName.createSimple( ColumnResult.class.getName() );
public static final DotName DISCRIMINATOR_COLUMN = DotName.createSimple( DiscriminatorColumn.class.getName() ); DotName DISCRIMINATOR_COLUMN = DotName.createSimple( DiscriminatorColumn.class.getName() );
public static final DotName DISCRIMINATOR_TYPE = DotName.createSimple( DiscriminatorType.class.getName() ); DotName DISCRIMINATOR_TYPE = DotName.createSimple( DiscriminatorType.class.getName() );
public static final DotName DISCRIMINATOR_VALUE = DotName.createSimple( DiscriminatorValue.class.getName() ); DotName DISCRIMINATOR_VALUE = DotName.createSimple( DiscriminatorValue.class.getName() );
public static final DotName ELEMENT_COLLECTION = DotName.createSimple( ElementCollection.class.getName() ); DotName ELEMENT_COLLECTION = DotName.createSimple( ElementCollection.class.getName() );
public static final DotName EMBEDDABLE = DotName.createSimple( Embeddable.class.getName() ); DotName EMBEDDABLE = DotName.createSimple( Embeddable.class.getName() );
public static final DotName EMBEDDED = DotName.createSimple( Embedded.class.getName() ); DotName EMBEDDED = DotName.createSimple( Embedded.class.getName() );
public static final DotName EMBEDDED_ID = DotName.createSimple( EmbeddedId.class.getName() ); DotName EMBEDDED_ID = DotName.createSimple( EmbeddedId.class.getName() );
public static final DotName ENTITY = DotName.createSimple( Entity.class.getName() ); DotName ENTITY = DotName.createSimple( Entity.class.getName() );
public static final DotName ENTITY_LISTENERS = DotName.createSimple( EntityListeners.class.getName() ); DotName ENTITY_LISTENERS = DotName.createSimple( EntityListeners.class.getName() );
public static final DotName ENTITY_RESULT = DotName.createSimple( EntityResult.class.getName() ); DotName ENTITY_RESULT = DotName.createSimple( EntityResult.class.getName() );
public static final DotName ENUMERATED = DotName.createSimple( Enumerated.class.getName() ); DotName ENUMERATED = DotName.createSimple( Enumerated.class.getName() );
public static final DotName ENUM_TYPE = DotName.createSimple( EnumType.class.getName() ); DotName ENUM_TYPE = DotName.createSimple( EnumType.class.getName() );
public static final DotName EXCLUDE_DEFAULT_LISTENERS = DotName.createSimple( ExcludeDefaultListeners.class.getName() ); DotName EXCLUDE_DEFAULT_LISTENERS = DotName.createSimple( ExcludeDefaultListeners.class.getName() );
public static final DotName EXCLUDE_SUPERCLASS_LISTENERS = DotName.createSimple( ExcludeSuperclassListeners.class.getName() ); DotName EXCLUDE_SUPERCLASS_LISTENERS = DotName.createSimple( ExcludeSuperclassListeners.class.getName() );
public static final DotName FETCH_TYPE = DotName.createSimple( FetchType.class.getName() ); DotName FETCH_TYPE = DotName.createSimple( FetchType.class.getName() );
public static final DotName FIELD_RESULT = DotName.createSimple( FieldResult.class.getName() ); DotName FIELD_RESULT = DotName.createSimple( FieldResult.class.getName() );
public static final DotName GENERATION_TYPE = DotName.createSimple( GenerationType.class.getName() ); DotName GENERATION_TYPE = DotName.createSimple( GenerationType.class.getName() );
public static final DotName GENERATED_VALUE = DotName.createSimple( GeneratedValue.class.getName() ); DotName GENERATED_VALUE = DotName.createSimple( GeneratedValue.class.getName() );
public static final DotName ID = DotName.createSimple( Id.class.getName() ); DotName ID = DotName.createSimple( Id.class.getName() );
public static final DotName ID_CLASS = DotName.createSimple( IdClass.class.getName() ); DotName ID_CLASS = DotName.createSimple( IdClass.class.getName() );
public static final DotName INHERITANCE_TYPE = DotName.createSimple( InheritanceType.class.getName() ); DotName INHERITANCE_TYPE = DotName.createSimple( InheritanceType.class.getName() );
public static final DotName JOIN_COLUMN = DotName.createSimple( JoinColumn.class.getName() ); DotName JOIN_COLUMN = DotName.createSimple( JoinColumn.class.getName() );
public static final DotName INHERITANCE = DotName.createSimple( Inheritance.class.getName() ); DotName INHERITANCE = DotName.createSimple( Inheritance.class.getName() );
public static final DotName JOIN_COLUMNS = DotName.createSimple( JoinColumns.class.getName() ); DotName JOIN_COLUMNS = DotName.createSimple( JoinColumns.class.getName() );
public static final DotName JOIN_TABLE = DotName.createSimple( JoinTable.class.getName() ); DotName JOIN_TABLE = DotName.createSimple( JoinTable.class.getName() );
public static final DotName LOB = DotName.createSimple( Lob.class.getName() ); DotName LOB = DotName.createSimple( Lob.class.getName() );
public static final DotName LOCK_MODE_TYPE = DotName.createSimple( LockModeType.class.getName() ); DotName LOCK_MODE_TYPE = DotName.createSimple( LockModeType.class.getName() );
public static final DotName MANY_TO_MANY = DotName.createSimple( ManyToMany.class.getName() ); DotName MANY_TO_MANY = DotName.createSimple( ManyToMany.class.getName() );
public static final DotName MANY_TO_ONE = DotName.createSimple( ManyToOne.class.getName() ); DotName MANY_TO_ONE = DotName.createSimple( ManyToOne.class.getName() );
public static final DotName MAP_KEY = DotName.createSimple( MapKey.class.getName() ); DotName MAP_KEY = DotName.createSimple( MapKey.class.getName() );
public static final DotName MAP_KEY_CLASS = DotName.createSimple( MapKeyClass.class.getName() ); DotName MAP_KEY_CLASS = DotName.createSimple( MapKeyClass.class.getName() );
public static final DotName MAP_KEY_COLUMN = DotName.createSimple( MapKeyColumn.class.getName() ); DotName MAP_KEY_COLUMN = DotName.createSimple( MapKeyColumn.class.getName() );
public static final DotName MAP_KEY_ENUMERATED = DotName.createSimple( MapKeyEnumerated.class.getName() ); DotName MAP_KEY_ENUMERATED = DotName.createSimple( MapKeyEnumerated.class.getName() );
public static final DotName MAP_KEY_JOIN_COLUMN = DotName.createSimple( MapKeyJoinColumn.class.getName() ); DotName MAP_KEY_JOIN_COLUMN = DotName.createSimple( MapKeyJoinColumn.class.getName() );
public static final DotName MAP_KEY_JOIN_COLUMNS = DotName.createSimple( MapKeyJoinColumns.class.getName() ); DotName MAP_KEY_JOIN_COLUMNS = DotName.createSimple( MapKeyJoinColumns.class.getName() );
public static final DotName MAP_KEY_TEMPORAL = DotName.createSimple( MapKeyTemporal.class.getName() ); DotName MAP_KEY_TEMPORAL = DotName.createSimple( MapKeyTemporal.class.getName() );
public static final DotName MAPPED_SUPERCLASS = DotName.createSimple( MappedSuperclass.class.getName() ); DotName MAPPED_SUPERCLASS = DotName.createSimple( MappedSuperclass.class.getName() );
public static final DotName MAPS_ID = DotName.createSimple( MapsId.class.getName() ); DotName MAPS_ID = DotName.createSimple( MapsId.class.getName() );
public static final DotName NAMED_NATIVE_QUERIES = DotName.createSimple( NamedNativeQueries.class.getName() ); DotName NAMED_NATIVE_QUERIES = DotName.createSimple( NamedNativeQueries.class.getName() );
public static final DotName NAMED_NATIVE_QUERY = DotName.createSimple( NamedNativeQuery.class.getName() ); DotName NAMED_NATIVE_QUERY = DotName.createSimple( NamedNativeQuery.class.getName() );
public static final DotName NAMED_QUERIES = DotName.createSimple( NamedQueries.class.getName() ); DotName NAMED_QUERIES = DotName.createSimple( NamedQueries.class.getName() );
public static final DotName NAMED_QUERY = DotName.createSimple( NamedQuery.class.getName() ); DotName NAMED_QUERY = DotName.createSimple( NamedQuery.class.getName() );
public static final DotName ONE_TO_MANY = DotName.createSimple( OneToMany.class.getName() ); DotName ONE_TO_MANY = DotName.createSimple( OneToMany.class.getName() );
public static final DotName ONE_TO_ONE = DotName.createSimple( OneToOne.class.getName() ); DotName ONE_TO_ONE = DotName.createSimple( OneToOne.class.getName() );
public static final DotName ORDER_BY = DotName.createSimple( OrderBy.class.getName() ); DotName ORDER_BY = DotName.createSimple( OrderBy.class.getName() );
public static final DotName ORDER_COLUMN = DotName.createSimple( OrderColumn.class.getName() ); DotName ORDER_COLUMN = DotName.createSimple( OrderColumn.class.getName() );
public static final DotName PERSISTENCE_CONTEXT = DotName.createSimple( PersistenceContext.class.getName() ); DotName PERSISTENCE_CONTEXT = DotName.createSimple( PersistenceContext.class.getName() );
public static final DotName PERSISTENCE_CONTEXTS = DotName.createSimple( PersistenceContexts.class.getName() ); DotName PERSISTENCE_CONTEXTS = DotName.createSimple( PersistenceContexts.class.getName() );
public static final DotName PERSISTENCE_PROPERTY = DotName.createSimple( PersistenceProperty.class.getName() ); DotName PERSISTENCE_PROPERTY = DotName.createSimple( PersistenceProperty.class.getName() );
public static final DotName PERSISTENCE_UNIT = DotName.createSimple( PersistenceUnit.class.getName() ); DotName PERSISTENCE_UNIT = DotName.createSimple( PersistenceUnit.class.getName() );
public static final DotName PERSISTENCE_UNITS = DotName.createSimple( PersistenceUnits.class.getName() ); DotName PERSISTENCE_UNITS = DotName.createSimple( PersistenceUnits.class.getName() );
public static final DotName POST_LOAD = DotName.createSimple( PostLoad.class.getName() ); DotName POST_LOAD = DotName.createSimple( PostLoad.class.getName() );
public static final DotName POST_PERSIST = DotName.createSimple( PostPersist.class.getName() ); DotName POST_PERSIST = DotName.createSimple( PostPersist.class.getName() );
public static final DotName POST_REMOVE = DotName.createSimple( PostRemove.class.getName() ); DotName POST_REMOVE = DotName.createSimple( PostRemove.class.getName() );
public static final DotName POST_UPDATE = DotName.createSimple( PostUpdate.class.getName() ); DotName POST_UPDATE = DotName.createSimple( PostUpdate.class.getName() );
public static final DotName PRE_PERSIST = DotName.createSimple( PrePersist.class.getName() ); DotName PRE_PERSIST = DotName.createSimple( PrePersist.class.getName() );
public static final DotName PRE_REMOVE = DotName.createSimple( PreRemove.class.getName() ); DotName PRE_REMOVE = DotName.createSimple( PreRemove.class.getName() );
public static final DotName PRE_UPDATE = DotName.createSimple( PreUpdate.class.getName() ); DotName PRE_UPDATE = DotName.createSimple( PreUpdate.class.getName() );
public static final DotName PRIMARY_KEY_JOIN_COLUMN = DotName.createSimple( PrimaryKeyJoinColumn.class.getName() ); DotName PRIMARY_KEY_JOIN_COLUMN = DotName.createSimple( PrimaryKeyJoinColumn.class.getName() );
public static final DotName PRIMARY_KEY_JOIN_COLUMNS = DotName.createSimple( PrimaryKeyJoinColumns.class.getName() ); DotName PRIMARY_KEY_JOIN_COLUMNS = DotName.createSimple( PrimaryKeyJoinColumns.class.getName() );
public static final DotName QUERY_HINT = DotName.createSimple( QueryHint.class.getName() ); DotName QUERY_HINT = DotName.createSimple( QueryHint.class.getName() );
public static final DotName SECONDARY_TABLE = DotName.createSimple( SecondaryTable.class.getName() ); DotName SECONDARY_TABLE = DotName.createSimple( SecondaryTable.class.getName() );
public static final DotName SECONDARY_TABLES = DotName.createSimple( SecondaryTables.class.getName() ); DotName SECONDARY_TABLES = DotName.createSimple( SecondaryTables.class.getName() );
public static final DotName SEQUENCE_GENERATOR = DotName.createSimple( SequenceGenerator.class.getName() ); DotName SEQUENCE_GENERATOR = DotName.createSimple( SequenceGenerator.class.getName() );
public static final DotName SQL_RESULT_SET_MAPPING = DotName.createSimple( SqlResultSetMapping.class.getName() ); DotName SQL_RESULT_SET_MAPPING = DotName.createSimple( SqlResultSetMapping.class.getName() );
public static final DotName SQL_RESULT_SET_MAPPINGS = DotName.createSimple( SqlResultSetMappings.class.getName() ); DotName SQL_RESULT_SET_MAPPINGS = DotName.createSimple( SqlResultSetMappings.class.getName() );
public static final DotName TABLE = DotName.createSimple( Table.class.getName() ); DotName TABLE = DotName.createSimple( Table.class.getName() );
public static final DotName TABLE_GENERATOR = DotName.createSimple( TableGenerator.class.getName() ); DotName TABLE_GENERATOR = DotName.createSimple( TableGenerator.class.getName() );
public static final DotName TEMPORAL = DotName.createSimple( Temporal.class.getName() ); DotName TEMPORAL = DotName.createSimple( Temporal.class.getName() );
public static final DotName TEMPORAL_TYPE = DotName.createSimple( TemporalType.class.getName() ); DotName TEMPORAL_TYPE = DotName.createSimple( TemporalType.class.getName() );
public static final DotName TRANSIENT = DotName.createSimple( Transient.class.getName() ); DotName TRANSIENT = DotName.createSimple( Transient.class.getName() );
public static final DotName UNIQUE_CONSTRAINT = DotName.createSimple( UniqueConstraint.class.getName() ); DotName UNIQUE_CONSTRAINT = DotName.createSimple( UniqueConstraint.class.getName() );
public static final DotName VERSION = DotName.createSimple( Version.class.getName() ); DotName VERSION = DotName.createSimple( Version.class.getName() );
} }

View File

@ -61,10 +61,10 @@ public class StringTypeDescriptor extends AbstractTypeDescriptor<String> {
return (X) value; return (X) value;
} }
if ( Reader.class.isAssignableFrom( type ) ) { if ( Reader.class.isAssignableFrom( type ) ) {
return (X) new StringReader( (String) value ); return (X) new StringReader( value );
} }
if ( CharacterStream.class.isAssignableFrom( type ) ) { if ( CharacterStream.class.isAssignableFrom( type ) ) {
return (X) new CharacterStreamImpl( (String) value ); return (X) new CharacterStreamImpl( value );
} }
if ( Clob.class.isAssignableFrom( type ) ) { if ( Clob.class.isAssignableFrom( type ) ) {
return (X) options.getLobCreator().createClob( value ); return (X) options.getLobCreator().createClob( value );

View File

@ -66,7 +66,7 @@ public class CustomerInventory implements Serializable, Comparator<CustomerInven
private int custId; private int custId;
@ManyToOne(cascade = CascadeType.MERGE) @ManyToOne(cascade = CascadeType.MERGE)
@JoinColumn(name = "CI_CUSTOMERID") @JoinColumn(name = "CI_CUSTOMERID", nullable = false)
private Customer customer; private Customer customer;
@ManyToOne(cascade = CascadeType.MERGE) @ManyToOne(cascade = CascadeType.MERGE)

View File

@ -1,6 +1,8 @@
package org.hibernate.test.annotations.derivedidentities.e2.b; package org.hibernate.test.annotations.derivedidentities.e2.b;
import javax.persistence.EmbeddedId; import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.MapsId; import javax.persistence.MapsId;
@ -13,10 +15,8 @@ public class Dependent {
DependentId id; DependentId id;
@MapsId("empPK") @MapsId("empPK")
// @JoinColumns({
// @JoinColumn(name = "FK1", referencedColumnName = "firstName"),
// @JoinColumn(name = "FK2", referencedColumnName = "lastName")
// })
@ManyToOne @ManyToOne
@JoinColumns( { @JoinColumn(nullable = false), @JoinColumn(nullable = false) })
Employee emp; Employee emp;
} }

View File

@ -61,8 +61,8 @@ import static org.junit.Assert.fail;
public class QueryAndSQLTest extends BaseCoreFunctionalTestCase { public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testNativeQueryWithFormulaAttribute() { public void testNativeQueryWithFormulaAttribute() {
String sql = "select t.table_name as {t.tableName}, sysdate() as {t.daysOld} from all_tables t where t.table_name = 'AUDIT_ACTIONS' "; String sql = "select t.table_name as {t.tableName}, sysdate() as {t.daysOld} from ALL_TABLES t where t.table_name = 'AUDIT_ACTIONS' ";
String sql2 = "select table_name as t_name, sysdate() as t_time from all_tables where table_name = 'AUDIT_ACTIONS' "; String sql2 = "select table_name as t_name, sysdate() as t_time from ALL_TABLES where table_name = 'AUDIT_ACTIONS' ";
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
s.createSQLQuery( sql ).addEntity( "t", AllTables.class ).list(); s.createSQLQuery( sql ).addEntity( "t", AllTables.class ).list();

View File

@ -26,6 +26,7 @@ import org.hibernate.Session;
import org.junit.Test; import org.junit.Test;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -91,8 +92,14 @@ public abstract class LongStringTest extends BaseCoreFunctionalTestCase {
s.beginTransaction(); s.beginTransaction();
entity = ( LongStringHolder ) s.get( LongStringHolder.class, entity.getId() ); entity = ( LongStringHolder ) s.get( LongStringHolder.class, entity.getId() );
if ( entity.getLongString() != null ) { if ( entity.getLongString() != null ) {
if(getDialect() instanceof SybaseASE15Dialect){
//Sybase uses a single blank to denote an empty string (this is by design). So, when inserting an empty string '', it is interpreted as single blank ' '.
assertEquals( empty.length(), entity.getLongString().trim().length() );
assertEquals( empty, entity.getLongString().trim() );
}else{
assertEquals( empty.length(), entity.getLongString().length() ); assertEquals( empty.length(), entity.getLongString().length() );
assertEquals( empty, entity.getLongString() ); assertEquals( empty, entity.getLongString() );
}
} }
s.delete( entity ); s.delete( entity );
s.getTransaction().commit(); s.getTransaction().commit();

View File

@ -34,6 +34,7 @@
<id name="id"/> <id name="id"/>
<one-to-many name="organization" target-entity="VicePresident"> <one-to-many name="organization" target-entity="VicePresident">
<map-key-class class="java.lang.String"/> <map-key-class class="java.lang.String"/>
<map-key-column name="organization_Key" nullable="false" />
</one-to-many> </one-to-many>
<element-collection name="conferenceRoomExtensions" target-class="java.lang.String"> <element-collection name="conferenceRoomExtensions" target-class="java.lang.String">
<map-key-class class="java.lang.String"/> <map-key-class class="java.lang.String"/>