@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; } }
@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); } }
private void setPrintInnerJoinOnClause(Session session) { boolean useInnerJoinOnClause = BooleanUtils.toBoolean( AppContext.getProperty("cuba.useInnerJoinOnClause")); session.getPlatform().setPrintInnerJoinInWhereClause(!useInnerJoinOnClause); } }
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"); }
if (!this.isCallbackRegistered && session.getPlatform().hasPartitioningCallback()) { session.getPlatform().getPartitioningCallback().register(dataSource, session); this.isCallbackRegistered = true;
if (!this.isCallbackRegistered && session.getPlatform().hasPartitioningCallback()) { session.getPlatform().getPartitioningCallback().register(dataSource, session); this.isCallbackRegistered = true;
Object proxyTypeValue = session.getProperty(PersistenceUnitProperties.ORACLE_PROXY_TYPE); try { proxyType = ((Integer)session.getPlatform().getConversionManager().convertObject(proxyTypeValue, Integer.class)).intValue(); } catch (ConversionException conversionException) { throw ValidationException.oracleJDBC10_1_0_2ProxyConnectorRequiresIntProxytype();
Object proxyTypeValue = session.getProperty(PersistenceUnitProperties.ORACLE_PROXY_TYPE); try { proxyType = ((Integer)session.getPlatform().getConversionManager().convertObject(proxyTypeValue, Integer.class)).intValue(); } catch (ConversionException conversionException) { throw ValidationException.oracleJDBC10_1_0_2ProxyConnectorRequiresIntProxytype();
/** * Given a DatabaseException, this method will determine if we should * throw a different more specific exception like a lock timeout exception. */ protected RuntimeException getDetailedException(DatabaseException e) { // If we catch a database exception as a result of executing a // pessimistic locking query we need to ask the platform which // JPA 2.0 locking exception we should throw. It will be either // be a PessimisticLockException or a LockTimeoutException (if // the query was executed using a wait timeout value) if (this.lockMode != null && this.lockMode.name().contains(ObjectLevelReadQuery.PESSIMISTIC_)) { // ask the platform if it is a lock timeout if (getActiveSession().getPlatform().isLockTimeoutException(e)) { return new LockTimeoutException(e); } else { return new PessimisticLockException(e); } } else { setRollbackOnly(); return new PersistenceException(e); } }
@Override protected void setSingleResult(XRServiceAdapter xrService, StoredProcedureCall spCall, QName resultType) { if (isCursorType(xrService, resultType)) { spCall.useUnnamedCursorOutputAsResultSet(); } else { StoredFunctionCall sfCall = (StoredFunctionCall)spCall; Class<?> clz = SCHEMA_2_CLASS.get(resultType); if (clz != null) { sfCall.setResult("", clz); } else { sfCall.setResult("", OBJECT); } DatabasePlatform platform = xrService.getORSession().getPlatform(); if (platform == null) { platform = new DatabasePlatform(); } // StoredFunction's return value is the first parameter ((DatabaseField)sfCall.getParameters().get(0)).setSqlType( platform.getJDBCType(clz)); } } }
@Override protected void setSingleResult(XRServiceAdapter xrService, StoredProcedureCall spCall, QName resultType) { if (isCursorType(xrService, resultType)) { spCall.useUnnamedCursorOutputAsResultSet(); } else { StoredFunctionCall sfCall = (StoredFunctionCall)spCall; Class<?> clz = SCHEMA_2_CLASS.get(resultType); if (clz != null) { sfCall.setResult("", clz); } else { sfCall.setResult("", OBJECT); } DatabasePlatform platform = xrService.getORSession().getPlatform(); if (platform == null) { platform = new DatabasePlatform(); } // StoredFunction's return value is the first parameter ((DatabaseField)sfCall.getParameters().get(0)).setSqlType( platform.getJDBCType(clz)); } } }
/** * Lookup the DynamicConversionManager for the given session. If the * existing ConversionManager is not an instance of DynamicConversionManager * then create a new one and replace the existing one. * * @param session * @return */ public static DynamicClassLoader lookup(Session session) { ConversionManager cm = null; if (session == null) { cm = ConversionManager.getDefaultManager(); } else { cm = session.getPlatform().getConversionManager(); } if (cm.getLoader() instanceof DynamicClassLoader) { return (DynamicClassLoader) cm.getLoader(); } DynamicClassLoader dcl = new DynamicClassLoader(cm.getLoader()); cm.setLoader(dcl); if (session == null) { ConversionManager.setDefaultLoader(dcl); } return dcl; }
/** * Lookup the DynamicConversionManager for the given session. If the * existing ConversionManager is not an instance of DynamicConversionManager * then create a new one and replace the existing one. * * @param session * @return */ public static DynamicClassLoader lookup(Session session) { ConversionManager cm = null; if (session == null) { cm = ConversionManager.getDefaultManager(); } else { cm = session.getPlatform().getConversionManager(); } if (cm.getLoader() instanceof DynamicClassLoader) { return (DynamicClassLoader) cm.getLoader(); } DynamicClassLoader dcl = new DynamicClassLoader(cm.getLoader()); cm.setLoader(dcl); if (session == null) { ConversionManager.setDefaultLoader(dcl); } return dcl; }
/** * Lookup the DynamicConversionManager for the given session. If the * existing ConversionManager is not an instance of DynamicConversionManager * then create a new one and replace the existing one. * * @param session * @return */ public static DynamicClassLoader lookup(Session session) { ConversionManager cm = null; if (session == null) { cm = ConversionManager.getDefaultManager(); } else { cm = session.getPlatform().getConversionManager(); } if (cm.getLoader() instanceof DynamicClassLoader) { return (DynamicClassLoader) cm.getLoader(); } DynamicClassLoader dcl = new DynamicClassLoader(cm.getLoader()); cm.setLoader(dcl); if (session == null) { ConversionManager.setDefaultLoader(dcl); } return dcl; }
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { driverClass = AccessController.doPrivileged(new PrivilegedClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader())); } catch (PrivilegedActionException exception) { throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName()); driverClass = PrivilegedAccessHelper.getClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader());
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { driverClass = AccessController.doPrivileged(new PrivilegedClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader())); } catch (PrivilegedActionException exception) { throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName()); driverClass = PrivilegedAccessHelper.getClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader());
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { driverClass = (Class)AccessController.doPrivileged(new PrivilegedClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader())); } catch (PrivilegedActionException exception) { throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName()); driverClass = org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader());
if (getActiveSession().getPlatform().isJDBCExecuteCompliant()) { throw new IllegalStateException(ExceptionLocalization.buildMessage("incorrect_spq_query_for_execute_update")); } else {