Package org.hibernate.type

Examples of org.hibernate.type.Type


  private String getCollectionRoleFromToOne(OgmEntityPersister associatedPersister) {
    //code logic is slightly duplicated but the input and context is different, hence this choice
    Type[] propertyTypes = associatedPersister.getPropertyTypes();
    String otherSidePropertyName = null;
    for ( int index = 0 ; index <  propertyTypes.length ; index++ ) {
      Type type = propertyTypes[index];
      boolean matching = false;
      //we try and restrict type search as much as possible
      //we look for associations that also are collections
      if ( type.isAssociationType() && type.isCollectionType() ) {
        matching = isCollectionMatching( (CollectionType) type, associationKeyMetadata.getTable() );
      }
      //we look for associations that are to-one
      else if ( type.isAssociationType() && ! type.isCollectionType() ) { //isCollectionType redundant but kept for readability
        matching = isToOneMatching( associatedPersister, index, type );
      }
      if ( matching ) {
        otherSidePropertyName = associatedPersister.getPropertyNames()[index];
        break;
View Full Code Here


    String otherSidePropertyName = null;
    Loadable elementPersister = (Loadable) collectionPersister.getElementPersister();
    Type[] propertyTypes = elementPersister.getPropertyTypes();

    for ( int index = 0 ; index <  propertyTypes.length ; index++ ) {
      Type type = propertyTypes[index];
      //we try and restrict type search as much as possible
      if ( type.isAssociationType() ) {
        boolean matching = false;
        //if the main side collection is a one-to-many, the reverse side should be a to-one is not a collection
        if ( collectionPersister.isOneToMany() && ! type.isCollectionType() ) {
          matching = isToOneMatching( elementPersister, index, type );
        }
        //if the main side collection is not a one-to-many, the reverse side should be a collection
        else if ( ! collectionPersister.isOneToMany() && type.isCollectionType() ) {
          matching = isCollectionMatching( (CollectionType) type, collectionPersister.getTableName() );
        }
        if ( matching ) {
          otherSidePropertyName = elementPersister.getPropertyNames()[index];
          break;
View Full Code Here

    customSQLDelete = new String[TABLE_SPAN];
  }

  private void initAssociationKeyMetadata() {
    for (int index = 0 ; index < getPropertySpan() ; index++) {
      final Type uniqueKeyType = getPropertyTypes()[index];
      if ( uniqueKeyType.isEntityType() ) {
        String[] propertyColumnNames = getPropertyColumnNames( index );
        String[] rowKeyColumnNames = buildRowKeyColumnNamesForStarToOne( this, propertyColumnNames );
        String tableName = getTableName();
        EntityKeyMetadata entityKeyMetadata = createTargetEntityKeyMetadatata( tableName, propertyColumnNames, rowKeyColumnNames );
        AssociationKeyMetadata metadata = new AssociationKeyMetadata(
View Full Code Here

    }
  }

  private GridType getUniqueKeyTypeFromAssociatedEntity(int propertyIndex, String propertyName) {
    GridType gridUniqueKeyType;//get the unique key type and if it's an entity type, get it's identifier type
    final Type uniqueKeyType = getPropertyTypes()[propertyIndex];
    if ( uniqueKeyType.isEntityType() ) {
      //we run under the assumption that we are fully in an OGM world
      EntityType entityType = (EntityType) uniqueKeyType;
      final OgmEntityPersister entityPersister = (OgmEntityPersister) entityType.getAssociatedJoinable( getFactory() );
      gridUniqueKeyType = entityPersister.getGridIdentifierType();
    }
View Full Code Here

      if ( !customQuery.getCustomQueryReturns().isEmpty() ) {
        entry = new Object[customQuery.getCustomQueryReturns().size()];
        int i = 0;
        for ( Return queryReturn : customQuery.getCustomQueryReturns() ) {
          ScalarReturn scalarReturn = (ScalarReturn) queryReturn;
          Type type = scalarReturn.getType();

          if ( type != null ) {
            GridType gridType = typeTranslator.getType( type );
            entry[i++] = gridType.nullSafeGet( tuple, scalarReturn.getColumnAlias(), session, null );
          }
View Full Code Here

      );
    }

    final AssociationType attributeType = (AssociationType) Helper.resolveType( sessionFactory(), attribute );
    final QueryableCollection collectionPersister = (QueryableCollection) attributeType.getAssociatedJoinable( sessionFactory() );
    final Type indexType = collectionPersister.getIndexType();

    if ( ! indexType.isAssociationType() ) {
      throw new IllegalArgumentException(
          String.format( "Map index [%s] is not an entity; cannot be target of key subgraph", getAttributeName() )
      );
    }
View Full Code Here

        column.getName(),
        sqlTypeCode.intValue(),
        column.getLength(), column.getPrecision(), column.getScale(), column.isNullable(), generatedIdentifier
    );

    Type wantedType = TypeFactory.heuristicType(preferredHibernateType);

    if(wantedType!=null) {
      int[] wantedSqlTypes = wantedType.sqlTypes(mapping);

      if(wantedSqlTypes.length>1) {
        throw new JDBCBinderException("The type " + preferredHibernateType + " found on " + location + " spans multiple columns. Only single column types allowed.");
      }
View Full Code Here

      for ( int i = 0; i < fields.length ; i++ ) {
        Field field = fields[i];
        if ( Modifier.isStatic( field.getModifiers() ) ) {
          if ( Type.class.isAssignableFrom( field.getType() ) ) {
            try {
              Type type = (Type) field.get( Hibernate.class );
              if ( !PRIMITIVES.containsKey( type.getName() ) ) {
                NONPRIMITIVETYPES.add( type.getName() );
              }
            }
            catch (IllegalArgumentException e) {
              throw new ExporterException( "Could not create list of basic hibernate types", e );
            }
View Full Code Here

    StringBuffer buf = new StringBuffer();
    Iterator iter = parameterTypes.entrySet().iterator();
    while ( iter.hasNext() ) {
      Map.Entry entry = (Map.Entry) iter.next();
      String typename = null;
      Type type = null;
      if(entry.getValue() instanceof String) {
        try {
          type = TypeFactory.heuristicType((String) entry.getValue());
        } catch(Throwable t) {
          type = null;
          typename = (String) entry.getValue();
        }
      }
     
      if(type!=null) {
        Class typeClass;
        if ( type instanceof PrimitiveType ) {
          typeClass = ( (PrimitiveType) type ).getPrimitiveClass();
        }
        else {
          typeClass = type.getReturnedClass();
        }
        typename = typeClass.getName();
      }
      buf.append( ctx.importType( typename ))
          .append( " " )
View Full Code Here

    // short-circuit(s)
    if ( currentElements.size()==0 ) return oldElements; // no new elements, the old list contains only Orphans
    if ( oldElements.size()==0) return oldElements; // no old elements, so no Orphans neither
   
    Type idType = session.getFactory().getEntityPersister(entityName).getIdentifierType();

    // create the collection holding the Orphans
    Collection res = new ArrayList();

    // collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access
View Full Code Here

TOP

Related Classes of org.hibernate.type.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.