org.eclipse.persistence.sessions.Session Java Examples

The following examples show how to use org.eclipse.persistence.sessions.Session. 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: PrefixSessionCustomizer.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public void customize(final Session session) throws Exception {
    if (JPAThreadContext.infos.containsKey("properties")) {
        final String prefix = ((Properties) JPAThreadContext.infos.get("properties")).getProperty("openejb.jpa.table_prefix");
        final List<DatabaseTable> tables = new ArrayList<DatabaseTable>();
        for (final ClassDescriptor cd : session.getDescriptors().values()) {
            for (final DatabaseTable table : cd.getTables()) {
                update(prefix, tables, table);
            }
            for (final DatabaseMapping mapping : cd.getMappings()) {
                if (mapping instanceof ManyToManyMapping) {
                    update(prefix, tables, ((ManyToManyMapping) mapping).getRelationTable());
                } else if (mapping instanceof DirectCollectionMapping) {
                    update(prefix, tables, ((DirectCollectionMapping) mapping).getReferenceTable());
                } // TODO: else check we need to update something
            }
        }

        final Sequence sequence = session.getDatasourcePlatform().getDefaultSequence();
        if (sequence instanceof TableSequence) {
            final TableSequence ts = ((TableSequence) sequence);
            ts.setName(prefix + ts.getName());
        }
    }
}
 
Example #2
Source File: QuestionnaireAnswersRepositoryImpl.java    From gazpachoquest with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void collectAnswers(final QuestionnaireDefinition questionnaireDefinition) {
    Assert.notNull(questionnaireDefinition.getId());
    final Session session = JpaHelper.getEntityManager(entityManager).getSession();
    // DynamicClassLoader dcl = new
    // DynamicClassLoader(Thread.currentThread().getContextClassLoader());
    final DynamicClassLoader dcl = DynamicClassLoader.lookup(session);

    // Create JPA Dynamic Helper (with the entityManager above) and after
    // the types
    // have been created and add the types through the helper.
    final JPADynamicHelper helper = new JPADynamicHelper(entityManager);
    helper.addTypes(true, true, buildDynamicType(dcl, questionnaireDefinition));
    // Update database
    new SchemaManager(helper.getSession()).createDefaultTables(true);

    logger.info("Questionnaire answer table has been created for questionnaireDefinition {}", questionnaireDefinition.getId());
}
 
Example #3
Source File: CamelNamingStrategy.java    From gazpachoquest with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void customize(final Session session) throws SQLException {
    for (ClassDescriptor descriptor : session.getDescriptors().values()) {
        if (!descriptor.getTables().isEmpty()) {
            // Take table name from @Table if exists
            String tableName = null;
            if (descriptor.getAlias().equalsIgnoreCase(descriptor.getTableName())) {
                tableName = unqualify(descriptor.getJavaClassName());
            } else {
                tableName = descriptor.getTableName();
            }
            tableName = camelCaseToUnderscore(tableName);
            descriptor.setTableName(tableName);

            for (IndexDefinition index : descriptor.getTables().get(0).getIndexes()) {
                index.setTargetTable(tableName);
            }
            Vector<DatabaseMapping> mappings = descriptor.getMappings();
            camelCaseToUnderscore(mappings);
        } else if (descriptor.isAggregateDescriptor() || descriptor.isChildDescriptor()) {
            camelCaseToUnderscore(descriptor.getMappings());
        }
    }
}
 
Example #4
Source File: DataGenerator.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
/**
 * This method deletes data from JPA tables created. This method reads comma
 * separated SQL delete statements from DataDeleteSQLs properties files and
 * executes them in order.
 */
public void clean() {
  // Delete using SQLs
  String[] deleteStatements = getSQLDeleteStatements();
  if (deleteStatements.length > 0) { // If configuration is proper with at least one delete Statements
    Session session = ((EntityManagerImpl) entityManager).getActiveSession();
    entityManager.getTransaction().begin();
    for (String deleteStatement : deleteStatements) {
      System.out.println("Cleaning - " + deleteStatement);
      SQLCall sqlCall = new SQLCall(deleteStatement);

      DataModifyQuery query = new DataModifyQuery();
      query.setCall(sqlCall);
      session.executeQuery(query);
    }
    entityManager.getTransaction().commit();
  } else {
    System.err.println("Delete configuration file doesn't have any delete statements.");
  }
}
 
Example #5
Source File: MapToStringConverter.java    From gazpachoquest with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Object convertObjectValueToDataValue(Object objectValue, Session session) {
    Validate.isInstanceOf(Map.class, objectValue);
    Map<String, String> map = (Map<String, String>) objectValue;
    if (map.isEmpty()) {
        return null;
    }
    Object dataValue = null;

    if (isPostgresProvider(session)) {
        dataValue = new PGHStore(map);
    } else {
        dataValue = HstoreSupport.toString(map);
    }
    return dataValue;
}
 
Example #6
Source File: UuidConverter.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public Object convertDataValueToObjectValue(Object dataValue, Session session) {
    try {
        if (session.getPlatform() instanceof PostgreSQLPlatform) {
            return dataValue;
        } else if (session.getPlatform() instanceof OraclePlatform
                || session.getPlatform() instanceof MySQLPlatform) {
            if (dataValue instanceof String) {
                StringBuilder sb = new StringBuilder((String) dataValue);
                sb.insert(8, '-');
                sb.insert(13, '-');
                sb.insert(18, '-');
                sb.insert(23, '-');
                return UuidProvider.fromString(sb.toString());
            } else {
                return dataValue;
            }
        } else {
            return dataValue instanceof String ? UuidProvider.fromString((String) dataValue) : dataValue;
        }
    } catch (Exception e) {
        throw new RuntimeException("Error creating UUID from database value '" + dataValue + "'", e);
    }
}
 
Example #7
Source File: KradEclipseLinkCustomizer.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void customize(Session session) throws Exception {
    String sessionName = session.getName();

    // double-checked locking on ConcurrentMap
    List<Sequence> sequences = sequenceMap.get(sessionName);
    if (sequences == null) {
        sequences = sequenceMap.putIfAbsent(sessionName, loadSequences(session));
        if (sequences == null) {
            sequences = sequenceMap.get(sessionName);
        }
    }

    loadQueryCustomizers(session);

    DatabaseLogin login = session.getLogin();
    for (Sequence sequence : sequences) {
        login.addSequence(sequence);
    }

    handleDescriptorModifications(session);

}
 
Example #8
Source File: KradEclipseLinkCustomizer.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * Checks class descriptors for {@link @DisableVersioning} annotations at the class level and removes the version
 * database mapping for optimistic locking.
 *
 * @param session the current session.
 */
protected void handleDisableVersioning(Session session) {
    Map<Class, ClassDescriptor> descriptors = session.getDescriptors();

    if (descriptors == null || descriptors.isEmpty()) {
        return;
    }

    for (ClassDescriptor classDescriptor : descriptors.values()) {
        if (classDescriptor != null && AnnotationUtils.findAnnotation(classDescriptor.getJavaClass(),
                DisableVersioning.class) != null) {
            OptimisticLockingPolicy olPolicy = classDescriptor.getOptimisticLockingPolicy();
            if (olPolicy != null) {
                classDescriptor.setOptimisticLockingPolicy(null);
            }
        }
    }
}
 
Example #9
Source File: KradEclipseLinkCustomizer.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * Determines if the class descriptors have been modified for the given session name.
 *
 * @param session the current session.
 */
protected void handleDescriptorModifications(Session session) {
    String sessionName = session.getName();

    // double-checked locking on ConcurrentMap
    Boolean descModified = modDescMap.get(sessionName);
    if (descModified == null) {
        descModified = modDescMap.putIfAbsent(sessionName, Boolean.FALSE);
        if (descModified == null) {
            descModified = modDescMap.get(sessionName);
        }
    }

    if (Boolean.FALSE.equals(descModified)) {
        modDescMap.put(sessionName, Boolean.TRUE);
        handleDisableVersioning(session);
        handleRemoveMapping(session);
    }
}
 
Example #10
Source File: UuidMappingProcessor.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void process(MappingProcessorContext context) {
    DatabaseMapping mapping = context.getMapping();
    Session session = context.getSession();

    MetaClass metaClass = metadata.getSession().getClassNN(mapping.getDescriptor().getJavaClass());

    String attributeName = mapping.getAttributeName();
    MetaProperty metaProperty = metaClass.getPropertyNN(attributeName);
    if (metaProperty.getRange().isDatatype()) {
        if (metaProperty.getJavaType().equals(UUID.class)) {
            ((DirectToFieldMapping) mapping).setConverter(UuidConverter.getInstance());
            setDatabaseFieldParameters(session, mapping.getField());
        }
    } else if (metaProperty.getRange().isClass() && !metaProperty.getRange().getCardinality().isMany()) {
        MetaClass refMetaClass = metaProperty.getRange().asClass();
        MetaProperty refPkProperty = metadata.getTools().getPrimaryKeyProperty(refMetaClass);
        if (refPkProperty != null && refPkProperty.getJavaType().equals(UUID.class)) {
            for (DatabaseField field : ((OneToOneMapping) mapping).getForeignKeyFields()) {
                setDatabaseFieldParameters(session, field);
            }
        }
    }

}
 
Example #11
Source File: UuidMappingProcessor.java    From cuba with Apache License 2.0 6 votes vote down vote up
private void setDatabaseFieldParameters(Session session, DatabaseField field) {
    if (session.getPlatform() instanceof PostgreSQLPlatform) {
        field.setSqlType(Types.OTHER);
        field.setType(UUID.class);
        field.setColumnDefinition("UUID");
    } else if (session.getPlatform() instanceof MySQLPlatform) {
        field.setSqlType(Types.VARCHAR);
        field.setType(String.class);
        field.setColumnDefinition("varchar(32)");
    } else if (session.getPlatform() instanceof HSQLPlatform) {
        field.setSqlType(Types.VARCHAR);
        field.setType(String.class);
        field.setColumnDefinition("varchar(36)");
    } else if (session.getPlatform() instanceof SQLServerPlatform) {
        field.setSqlType(Types.VARCHAR);
        field.setType(String.class);
        field.setColumnDefinition("uniqueidentifier");
    } else if (session.getPlatform() instanceof OraclePlatform) {
        field.setSqlType(Types.VARCHAR);
        field.setType(String.class);
        field.setColumnDefinition("varchar2(32)");
    } else {
        field.setSqlType(Types.VARCHAR);
        field.setType(String.class);
    }
}
 
Example #12
Source File: KradEclipseLinkCustomizer.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * Load Query Customizer based on annotations on fields and call customizer to modify descriptor.
 *
 * @param session the EclipseLink session.
 */
protected void loadQueryCustomizers(Session session) {
    Map<Class, ClassDescriptor> descriptors = session.getDescriptors();
    for (Class<?> entityClass : descriptors.keySet()) {
        for (Field field : entityClass.getDeclaredFields()) {
            String queryCustEntry = entityClass.getName() + "_" + field.getName();
            buildQueryCustomizers(entityClass,field,queryCustEntry);

            List<FilterGenerator> queryCustomizers = queryCustomizerMap.get(queryCustEntry);
            if (queryCustomizers != null && !queryCustomizers.isEmpty()) {
                Filter.customizeField(queryCustomizers, descriptors.get(entityClass), field.getName());
            }
        }
    }

}
 
Example #13
Source File: ForgetfulnessService.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public static void freeMemory() {
	AdminDatabase.instance().log(Level.WARNING, "Low memory detected, clearing all caches");
	Stats.stats.memoryFrees++;
	AdminDatabase.instance().log(Level.WARNING, "Clearing instance cache");
	BotManager.manager().clearCache();
	// Reduce size to free memory.
	BotManager.manager().setMaxSize((int)(Site.MAX_BOT_CACHE_SIZE * 0.8));
	AdminDatabase.instance().log(Level.WARNING, "Clearing bean cache");
	BeanManager.manager().clearCache();
	AdminDatabase.instance().log(Level.WARNING, "Clearing instance pool");
	Bot.clearPool();

	AdminDatabase.instance().log(Level.WARNING, "Clearing instance caches");
	for (DatabaseMemory.SessionInfo info : DatabaseMemory.sessions.values()) {
		if (info.session != null) {
			info.session.getIdentityMapAccessor().initializeAllIdentityMaps();
		}
	}
	for (Object value : SessionManager.getManager().getSessions().values()) {
		((Session)value).getIdentityMapAccessor().initializeAllIdentityMaps();
	}

	AdminDatabase.instance().log(Level.WARNING, "Running GC");
	System.gc();
	AdminDatabase.instance().log(Level.WARNING, "Running finalization");
	System.runFinalization();
	Utils.sleep(5000);
	Bot.clearPool();
	AdminDatabase.instance().log(Level.WARNING, "Done");
}
 
Example #14
Source File: JPAMTableCreator.java    From jeddict with Apache License 2.0 5 votes vote down vote up
/**
 * This returns the Sequence Table's qualified name, without delimiting.
 *
 * @param session
 * @return the qualified table name
 */
protected String getSequenceTableName(Session session) {
    String sequenceTableName = null;
    if (session.getProject().usesSequencing()) {
        Sequence sequence = session.getLogin().getDefaultSequence();
        if (sequence instanceof TableSequence) {
            sequenceTableName = ((TableSequence) sequence).getQualifiedTableName();
        }
    }
    return sequenceTableName;
}
 
Example #15
Source File: DataGenerator.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
/**
   * This method generates data to be used in the application. It does so by
   * reading properties file. Currently it iterates through comma separated
   * file names in file SQLInsertConfig and gets the insert statements from
   * those files in the order provided in the file.
   */
  public void generate() {
    String[] resourceSQLPropFileNames = getSQLInsertFileNames();
    if (resourceSQLPropFileNames.length > 0) { // If configuration is proper with at least one file
      Session session = ((EntityManagerImpl) entityManager).getActiveSession();
      ResourceBundle[] resourceBundleArr = new ResourceBundle[resourceSQLPropFileNames.length];
      entityManager.getTransaction().begin();

      for (int i = 0; i < resourceSQLPropFileNames.length; i++) { // For each Entity SQL property file,
        System.out.println("Reading from File - " + resourceSQLPropFileNames[i]);
        resourceBundleArr[i] = ResourceBundle.getBundle(resourceSQLPropFileNames[i]);// Get SQL statements as properties

        Set<String> keySet = resourceBundleArr[i].keySet();
        List<String> queryNames = new ArrayList<String>(keySet);
        Collections.sort(queryNames);

        for (String queryName : queryNames) {
//        while(keySet.hasMoreElements()) {
          String sqlQuery = resourceBundleArr[i].getString(queryName);
          System.out.println("Executing Query - " + sqlQuery);
          SQLCall sqlCall = new SQLCall(sqlQuery);

          DataModifyQuery query = new DataModifyQuery();
          query.setCall(sqlCall);
          session.executeQuery(query);
        }
      }
      setMaterialInStore();
      entityManager.flush();
      entityManager.getTransaction().commit();
    }

  }
 
Example #16
Source File: KradEclipseLinkCustomizer.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Checks class descriptors for {@link @RemoveMapping} and {@link RemoveMappings} annotations at the class level
 * and removes any specified mappings from the ClassDescriptor.
 *
 * @param session the current session.
 */
protected void handleRemoveMapping(Session session) {
    Map<Class, ClassDescriptor> descriptors = session.getDescriptors();

    if (descriptors == null || descriptors.isEmpty()) {
        return;
    }

    for (ClassDescriptor classDescriptor : descriptors.values()) {
        List<DatabaseMapping> mappingsToRemove = new ArrayList<DatabaseMapping>();
        List<RemoveMapping> removeMappings = scanForRemoveMappings(classDescriptor);

        for (RemoveMapping removeMapping : removeMappings) {
            if (StringUtils.isBlank(removeMapping.name())) {
                throw DescriptorException.attributeNameNotSpecified();
            }

            DatabaseMapping databaseMapping = classDescriptor.getMappingForAttributeName(removeMapping.name());

            if (databaseMapping == null) {
                throw DescriptorException.mappingForAttributeIsMissing(removeMapping.name(), classDescriptor);
            }

            mappingsToRemove.add(databaseMapping);
        }

        for (DatabaseMapping mappingToRemove : mappingsToRemove) {
            classDescriptor.removeMappingForAttributeName(mappingToRemove.getAttributeName());
        }
    }
}
 
Example #17
Source File: MapToStringConverter.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Object convertDataValueToObjectValue(Object dataValue, Session session) {
    Object objectValue = null;
    if (dataValue == null) {
        return new HashMap<>();
    }
    if (dataValue instanceof Map) {
        objectValue = dataValue;
    } else if (dataValue instanceof String) {
        objectValue = HstoreSupport.toMap((String) objectValue);
    } else {
        throw new IllegalStateException(dataValue + " is not a valid map representation");
    }
    return objectValue;
}
 
Example #18
Source File: MapToStringConverter.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initialize(DatabaseMapping mapping, Session session) {
    if (isPostgresProvider(session)) {
        mapping.getField().setSqlType(java.sql.Types.OTHER);
    } else {
        mapping.getField().setSqlType(java.sql.Types.VARCHAR);
    }

}
 
Example #19
Source File: QuestionnaireAnswersRepositoryImpl.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Transactional
public void activeAllAnswers() {
    final Session session = JpaHelper.getEntityManager(entityManager).getSession();
    final DynamicClassLoader dcl = DynamicClassLoader.lookup(session);

    final List<QuestionnaireDefinition> confirmedSurveys = questionnaireDefinitionRepository.findByExample(
            QuestionnaireDefinition.with().status(EntityStatus.CONFIRMED).build(), new SearchParameters());

    final List<DynamicType> dynamicTypes = new ArrayList<>();
    final JPADynamicHelper helper = new JPADynamicHelper(entityManager);

    for (final QuestionnaireDefinition questionnaireDefinition : confirmedSurveys) {
        final String entityAlias = new StringBuilder().append(ENTITY_NAME_PREFIX).append(questionnaireDefinition.getId()).toString();
        final DynamicType type = helper.getType(entityAlias);
        if (type == null) {
            dynamicTypes.add(buildDynamicType(dcl, questionnaireDefinition));
        }
    }
    if (!dynamicTypes.isEmpty()) {
        helper.addTypes(true, true, dynamicTypes.toArray(new DynamicType[dynamicTypes.size()]));
    }
    logger.info("{} questionnaire answer tables has been activated", confirmedSurveys.size());

    // Update database
    new SchemaManager(helper.getSession()).createDefaultTables(true);

}
 
Example #20
Source File: EclipseLinkSessionEventListener.java    From cuba with Apache License 2.0 5 votes vote down vote up
private void setCacheable(MetaClass metaClass, ClassDescriptor desc, Session session) {
    String property = (String) session.getProperty("eclipselink.cache.shared.default");
    boolean defaultCache = property == null || Boolean.valueOf(property);

    if ((defaultCache && !desc.isIsolated())
            || desc.getCacheIsolation() == CacheIsolationType.SHARED
            || desc.getCacheIsolation() == CacheIsolationType.PROTECTED) {
        metaClass.getAnnotations().put("cacheable", true);
        desc.getCachePolicy().setCacheCoordinationType(CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS);
    }
}
 
Example #21
Source File: EclipseLinkSessionCustomizer.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Customize the session.
 * 
 * @param session the session.
 * @throws Exception when a serious error occurs.
 */
@Override
public void customize(Session session) throws Exception {
    InitialContext initialContext = new InitialContext();
    TransactionManager transactionManager = (TransactionManager) initialContext.lookup("java:/TransactionManager");
    session.setExternalTransactionController(new JTATransactionController(transactionManager));
}
 
Example #22
Source File: JNDICustomizer.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public void customize(Session session) throws Exception {
	Connector connector = session.getLogin().getConnector();
	if(connector instanceof JNDIConnector) {
		 JNDIConnector jndiConnector = (JNDIConnector) session.getLogin().getConnector();
		 jndiConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
	}
}
 
Example #23
Source File: JPQL2SQLStatementRewriter.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Rewrite the JPQL query in a SQL String (The persistence provider implementation in use is EclipseLink)
 * 
 * @param query
 *            The JPQL query
 * @return the string of the JPQL query translated in SQL
 */
private String rewriteEclipseLink(Query query) {
	EJBQueryImpl qi = (EJBQueryImpl) query;
	Session session = this.entityManager.unwrap(JpaEntityManager.class).getActiveSession();
	DatabaseQuery databaseQuery = (qi).getDatabaseQuery();
	databaseQuery.prepareCall(session, new DatabaseRecord());
	String sqlString = databaseQuery.getTranslatedSQLString(session, new DatabaseRecord());

	// ADD THE ALIAS in the select statement (necessary for the temporary table construction..)
	int fromPosition = sqlString.indexOf("FROM");
	StringBuffer sqlQuery2 = new StringBuffer();
	String SelectStatement = sqlString.substring(0, fromPosition - 1);
	StringTokenizer SelectStatementStk = new StringTokenizer(SelectStatement, ",");
	int i = 0;
	while (SelectStatementStk.hasMoreTokens()) {
		sqlQuery2.append(SelectStatementStk.nextToken());
		sqlQuery2.append(" as alias");
		sqlQuery2.append(i);
		sqlQuery2.append(",");
		i++;
	}
	sqlQuery2.delete(sqlQuery2.length() - 1, sqlQuery2.length());
	sqlQuery2.append(sqlString.substring(fromPosition - 1));

	logger.debug("JPQL QUERY: " + sqlQuery2);

	return sqlQuery2.toString();
}
 
Example #24
Source File: StudioEclipseLinkSessionEventListener.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void preLogin(SessionEvent event) {
    Session session = event.getSession();


    Map<Class, ClassDescriptor> descriptorMap = session.getDescriptors();
    for (Map.Entry<Class, ClassDescriptor> entry : descriptorMap.entrySet()) {
        ClassDescriptor desc = entry.getValue();

        if (SoftDelete.class.isAssignableFrom(desc.getJavaClass())) {
            desc.getQueryManager().setAdditionalCriteria("this.deleteTs is null");
            desc.setDeletePredicate(entity -> entity instanceof SoftDelete &&
                    PersistenceHelper.isLoaded(entity, "deleteTs") &&
                    ((SoftDelete) entity).isDeleted());
        }

        List<DatabaseMapping> mappings = desc.getMappings();
        Class entityClass = entry.getKey();

        for (DatabaseMapping mapping : mappings) {
            if (UUID.class.equals(getFieldType(entityClass, mapping.getAttributeName()))) {
                ((DirectToFieldMapping) mapping).setConverter(UuidConverter.getInstance());
                setDatabaseFieldParameters(session, mapping.getField());
            }
        }
    }
}
 
Example #25
Source File: UuidConverter.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public Object convertObjectValueToDataValue(Object objectValue, Session session) {
    if (session.getPlatform() instanceof PostgreSQLPlatform) {
        return objectValue;
    } else if (session.getPlatform() instanceof SQLServerPlatform) {
        return objectValue != null ? objectValue.toString().toUpperCase() : null; // for correct binding of batch query results
    } else if (session.getPlatform() instanceof OraclePlatform
            || session.getPlatform() instanceof MySQLPlatform) {
        return objectValue != null ? objectValue.toString().replace("-", "") : null;
    } else {
        return objectValue != null ? objectValue.toString() : null;
    }
}
 
Example #26
Source File: StudioEclipseLinkSessionEventListener.java    From cuba with Apache License 2.0 5 votes vote down vote up
private void setDatabaseFieldParameters(Session session, DatabaseField field) {
    if (session.getPlatform() instanceof PostgreSQLPlatform) {
        field.setSqlType(Types.OTHER);
        field.setType(UUID.class);
    } else {
        field.setSqlType(Types.VARCHAR);
        field.setType(String.class);
    }
    field.setColumnDefinition("UUID");
}
 
Example #27
Source File: SessionLogDelegate.java    From recheck with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setSession( final Session session ) {
	delegate.setSession( session );
}
 
Example #28
Source File: SessionLogDelegate.java    From recheck with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Session getSession() {
	return delegate.getSession();
}
 
Example #29
Source File: MBeanOpenEJBRuntimeServices.java    From tomee with Apache License 2.0 4 votes vote down vote up
public MBeanOpenEJBRuntimeServices(Session session) {
    super((AbstractSession) session);
}
 
Example #30
Source File: MapToStringConverter.java    From gazpachoquest with GNU General Public License v3.0 4 votes vote down vote up
public boolean isPostgresProvider(Session session) {
    return (session.getPlatform() instanceof PostgreSQLPlatform);
}