public void setSqlOrderBy(OrderBy orderByAnn) { if ( orderByAnn != null ) { if ( !BinderHelper.isDefault( orderByAnn.clause() ) ) orderBy = orderByAnn.clause(); } }
private static void bindAnyMetaDef(AnyMetaDef defAnn, ExtendedMappings mappings) { if ( isDefault( defAnn.name() ) ) return; //don't map not named definitions log.info( "Binding Any Meta definition: {}", defAnn.name() ); mappings.addAnyMetaDef( defAnn ); }
private static void checkAnyMetaDefValidity(boolean mustHaveName, AnyMetaDef defAnn, XAnnotatedElement annotatedElement) { if ( mustHaveName && isDefault( defAnn.name() ) ) { String name = XClass.class.isAssignableFrom( annotatedElement.getClass() ) ? ( (XClass) annotatedElement ).getName() : ( (XPackage) annotatedElement ).getName(); throw new AnnotationException( "@AnyMetaDef.name cannot be null on an entity or a package: " + name ); } }
private static void bindTypeDef(TypeDef defAnn, ExtendedMappings mappings) { Properties params = new Properties(); for ( Parameter param : defAnn.parameters() ) { params.setProperty( param.name(), param.value() ); } if ( BinderHelper.isDefault( defAnn.name() ) && defAnn.defaultForType().equals( void.class ) ) { throw new AnnotationException( "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " + defAnn.typeClass().getName() ); } if ( !BinderHelper.isDefault( defAnn.name() ) ) { log.info( "Binding type definition: {}", defAnn.name() ); mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params ); } if ( !defAnn.defaultForType().equals( void.class ) ) { log.info( "Binding type definition: {}", defAnn.defaultForType().getName() ); mappings.addTypeDef( defAnn.defaultForType().getName(), defAnn.typeClass().getName(), params ); } }
public void setCache(Cache cacheAnn) { if ( cacheAnn != null ) { cacheRegionName = BinderHelper.isDefault( cacheAnn.region() ) ? null : cacheAnn.region(); cacheConcurrencyStrategy = EntityBinder.getCacheConcurrencyStrategy( cacheAnn.usage() ); } else { cacheConcurrencyStrategy = null; cacheRegionName = null; } }
private void bindEjb3Annotation(Entity ejb3Ann) { if ( ejb3Ann == null ) throw new AssertionFailure( "@Entity should always be not null" ); if ( BinderHelper.isDefault( ejb3Ann.name() ) ) { name = StringHelper.unqualify( annotatedClass.getName() ); } else { name = ejb3Ann.name(); } }
private String getCondition(String cond, String name) { if ( BinderHelper.isDefault( cond ) ) { cond = mappings.getFilterDefinition( name ).getDefaultFilterCondition(); if ( StringHelper.isEmpty( cond ) ) { throw new AnnotationException( "no filter condition found for filter " + name + " in " + StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); } } return cond; }
); if ( !BinderHelper.isDefault( table.comment() ) ) hibTable.setComment( table.comment() ); TableBinder.addIndexes( hibTable, table.indexes(), mappings );
public void setCache(Cache cacheAnn) { if ( cacheAnn != null ) { cacheRegion = BinderHelper.isDefault( cacheAnn.region() ) ? null : cacheAnn.region(); cacheConcurrentStrategy = getCacheConcurrencyStrategy( cacheAnn.usage() ); if ( "all".equalsIgnoreCase( cacheAnn.include() ) ) { cacheLazyProperty = true; } else if ( "non-lazy".equalsIgnoreCase( cacheAnn.include() ) ) { cacheLazyProperty = false; } else { throw new AnnotationException( "Unknown lazy property annotations: " + cacheAnn.include() ); } } else { cacheConcurrentStrategy = null; cacheRegion = null; cacheLazyProperty = true; } }
private void setFKNameIfDefined(Join join) { org.hibernate.annotations.Table matchingTable = findMatchingComplimentTableAnnotation( join ); if ( matchingTable != null && !BinderHelper.isDefault( matchingTable.foreignKey().name() ) ) { ( (SimpleValue) join.getKey() ).setForeignKeyName( matchingTable.foreignKey().name() ); } }
public void fillSimpleValue() { log.debug( "setting SimpleValue typeName for {}", propertyName ); String type = BinderHelper.isDefault( explicitType ) ? returnedClassName : explicitType; org.hibernate.mapping.TypeDef typeDef = mappings.getTypeDef( type ); if ( typeDef != null ) { type = typeDef.getTypeClass(); simpleValue.setTypeParameters( typeDef.getParameters() ); } if ( typeParameters != null && typeParameters.size() != 0 ) { //explicit type params takes precedence over type def params simpleValue.setTypeParameters( typeParameters ); } simpleValue.setTypeName( type ); if ( persistentClassName != null ) { simpleValue.setTypeUsingReflection( persistentClassName, propertyName ); } if ( !simpleValue.isTypeSpecified() && isVersion()) { simpleValue.setTypeName( "integer" ); } }
public static IndexColumn buildColumnFromAnnotation( org.hibernate.annotations.IndexColumn ann, PropertyHolder propertyHolder, PropertyData inferredData, ExtendedMappings mappings ) { IndexColumn column; if ( ann != null ) { String sqlType = BinderHelper.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition(); String name = BinderHelper.isDefault( ann.name() ) ? inferredData.getPropertyName() : ann.name(); //TODO move it to a getter based system and remove the constructor column = new IndexColumn( false, sqlType, 0, 0, 0, name, ann.nullable(), false, true, true, null, null, propertyHolder, mappings ); column.setBase( ann.base() ); } else { column = new IndexColumn( true, null, 0, 0, 0, null, true, false, true, true, null, null, propertyHolder, mappings ); } return column; } }
public static void bindQuery(org.hibernate.annotations.NamedQuery queryAnn, ExtendedMappings mappings) { if ( queryAnn == null ) return; if ( BinderHelper.isDefault( queryAnn.name() ) ) { throw new AnnotationException( "A named query must have a name when used in class or package level" ); } FlushMode flushMode; flushMode = getFlushMode( queryAnn.flushMode() ); NamedQueryDefinition query = new NamedQueryDefinition( queryAnn.query(), queryAnn.cacheable(), BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(), queryAnn.timeout() < 0 ? null : queryAnn.timeout(), queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(), flushMode, getCacheMode( queryAnn.cacheMode() ), queryAnn.readOnly(), BinderHelper.isDefault( queryAnn.comment() ) ? null : queryAnn.comment(), null ); mappings.addQuery( queryAnn.name(), query ); if ( log.isInfoEnabled() ) log.info( "Binding named query: " + queryAnn.name() + " => " + queryAnn.query() ); }
public static void bindNativeQuery(org.hibernate.annotations.NamedNativeQuery queryAnn, ExtendedMappings mappings) { if ( queryAnn == null ) return; if ( BinderHelper.isDefault( queryAnn.name() ) ) { throw new AnnotationException( "A named query must have a name when used in class or package level" ); if ( !BinderHelper.isDefault( resultSetMapping ) ) { null, queryAnn.cacheable(), BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(), queryAnn.timeout() < 0 ? null : queryAnn.timeout(), queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(), null, queryAnn.cacheable(), BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(), queryAnn.timeout() < 0 ? null : queryAnn.timeout(), queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(),
public void setJoinAnnotation(JoinColumn annJoin, String defaultName) { if ( annJoin == null ) { setImplicit( true ); } else { setImplicit( false ); if ( !BinderHelper.isDefault( annJoin.columnDefinition() ) ) setSqlType( annJoin.columnDefinition() ); if ( !BinderHelper.isDefault( annJoin.name() ) ) setLogicalColumnName( annJoin.name() ); setNullable( annJoin.nullable() ); setUnique( annJoin.unique() ); setInsertable( annJoin.insertable() ); setUpdatable( annJoin.updatable() ); setReferencedColumn( annJoin.referencedColumnName() ); setSecondaryTableName( annJoin.table() ); } }
public static void bindQuery(NamedQuery queryAnn, ExtendedMappings mappings, boolean isDefault) { if ( queryAnn == null ) return; if ( BinderHelper.isDefault( queryAnn.name() ) ) { throw new AnnotationException( "A named query must have a name when used in class or package level" ); } //EJBQL Query QueryHint[] hints = queryAnn.hints(); String queryName = queryAnn.query(); NamedQueryDefinition query = new NamedQueryDefinition( queryName, getBoolean( queryName, "org.hibernate.cacheable", hints ), getString( queryName, "org.hibernate.cacheRegion", hints ), getTimeout( queryName, hints ), getInteger( queryName, "org.hibernate.fetchSize", hints ), getFlushMode( queryName, hints ), getCacheMode( queryName, hints ), getBoolean( queryName, "org.hibernate.readOnly", hints ), getString( queryName, "org.hibernate.comment", hints ), null ); if ( isDefault ) { mappings.addDefaultQuery( queryAnn.name(), query ); } else { mappings.addQuery( queryAnn.name(), query ); } log.info( "Binding Named query: {} => {}", queryAnn.name(), queryAnn.query() ); }
ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null; String fkName = fk != null ? fk.name() : ""; if ( !BinderHelper.isDefault( fkName ) ) key.setForeignKeyName( fkName ); return key;