/** INTERNAL: Return the create table statement. */ public Writer buildCreationWriter(AbstractSession session, Writer writer) throws ValidationException { try { DatabasePlatform platform = session.getPlatform(); writer.write("CREATE PACKAGE " + getFullName()); writer.write(" AS"); writer.write("\n"); for (Enumeration statementsEnum = getStatements().elements(); statementsEnum.hasMoreElements(); ) { writer.write((String) statementsEnum.nextElement()); writer.write(platform.getBatchDelimiterString()); writer.write("\n"); } for (Enumeration proceduresEnum = getProcedures().elements(); proceduresEnum.hasMoreElements(); ) { writer.write("\n"); String procedureString = ((StoredProcedureDefinition) proceduresEnum.nextElement()) .buildCreationWriter(session, writer) .toString(); writer.write(procedureString.substring(7, procedureString.length())); writer.write("\n"); } writer.write(platform.getBatchEndString()); writer.write("\n" + session.getPlatform().getStoredProcedureTerminationToken()); } catch (IOException ioException) { throw ValidationException.fileError(ioException); } return writer; }
public static boolean supportsStoredFunctions(String puName) { DatabasePlatform platform = getDatabaseSession(puName).getPlatform(); // PostgreSQL has some level of support for "stored functions", but output parameters do not // work as of 8.2. // TODO: DB2 should be in this list. if (platform.isOracle() || platform.isMySQL()) { return true; } warning("This database does not support stored function creation."); return false; }
public static boolean supportsStoredProcedures(String puName) { DatabasePlatform platform = getDatabaseSession(puName).getPlatform(); // PostgreSQL has some level of support for "stored functions", but output parameters do not // work as of 8.2. // Sybase supports stored procedures, but has issues with output parameters and transaction mode // (INOUT and chaining). // TODO: DB2 should be in this list. if (platform.isOracle() || platform.isMySQL() || platform.isSQLServer()) { return true; } warning("This database does not support stored procedure creation."); return false; }
public static Class<?> getClassFromJDBCType(String typeName, DatabasePlatform databasePlatform) { Class<?> clz = databasePlatform.getClassTypes().get(typeName); if (clz == null) { return Object_Class; } return clz; }
protected static void afterAddDescriptors(Session session, TestSystem aTestSystem) { if (aTestSystem instanceof InheritanceSystem) { // For using read all subclasses views. org.eclipse.persistence.internal.databaseaccess.DatabasePlatform platform = session.getLogin().getPlatform(); if (platform.isOracle() || platform.isSybase() || platform.isSQLAnywhere()) { ClassDescriptor computerDescriptor = session.getClassDescriptor(Computer.class); ClassDescriptor vehicleDescriptor = session.getClassDescriptor(Vehicle.class); if (computerDescriptor.getInheritancePolicy().requiresMultipleTableSubclassRead()) { computerDescriptor.getInheritancePolicy().setReadAllSubclassesViewName("AllComputers"); } if (vehicleDescriptor.getInheritancePolicy().requiresMultipleTableSubclassRead()) { vehicleDescriptor.getInheritancePolicy().setReadAllSubclassesViewName("AllVehicles"); } } } }
public static boolean isPessimisticWriteLockSupported(DatabasePlatform platform) { if (platform .isSybase()) { // Sybase supports getting Pessimistic Read locks but does not support // getting Perssimistic Write locks warning("This database does not support Pessimistic Write Lock."); return false; } return true; }
public void addDescriptors(DatabaseSession session) { // Oracle has bug in outjoins that require outerjoin of inheritance type. // This should really be handled by the platform during expression normalization... // Id for Entomologist can be negative (millis cast to int wraps...) project.getDescriptor(Entomologist.class).setIdValidation(IdValidation.NONE); session.addDescriptors(project); // For using read all subclasses views. DatabasePlatform platform = session.getLogin().getPlatform(); if (platform.isOracle() || platform.isSybase()) { ClassDescriptor computerDescriptor = session.getDescriptor(Computer.class); ClassDescriptor vehicleDescriptor = session.getDescriptor(Vehicle.class); computerDescriptor.getInheritancePolicy().setReadAllSubclassesViewName("AllComputers"); vehicleDescriptor.getInheritancePolicy().setReadAllSubclassesViewName("AllVehicles"); } // Enable outer-join on AnimalMatt hierarchy. session .getDescriptor(Animal_Matt.class) .getInheritancePolicy() .setShouldOuterJoinSubclasses(true); }
public static boolean isSelectForUpateSupported(DatabasePlatform platform) { // DB2, Derby, Symfoware (bug 304903) and Firebird support pessimistic locking only for a // single-table queries. // PostgreSQL supports for update, but not on outerjoins, which the test uses. // H2 supports pessimistic locking, but has table lock issues with multiple connections used in // the tests. if (platform.isFirebird() || platform.isH2() || platform.isHSQL() || platform.isAccess() || platform.isSQLAnywhere() || platform.isDerby() || platform.isPostgreSQL() || platform.isSymfoware()) { warning("This database does not support FOR UPDATE."); return false; } return true; }
/** Also creates the procs. */ public void createTables(DatabaseSession session) { super.createTables(session); org.eclipse.persistence.internal.databaseaccess.DatabasePlatform platform = session.getLogin().getPlatform(); SchemaManager schema = new SchemaManager((session)); if (platform.isSQLServer()) {} if (platform.isSybase() || platform.isSQLAnywhere()) {} if (platform.isOracle()) { schema.replaceObject(buildOracleStoredProcedureInsertPolicyHolders()); schema.replaceObject(buildOracleStoredProcedureReadFromPolicyHolders()); schema.replaceObject(buildOracleStoredProcedureDeletePolicyHolders()); } if (platform.isDB2()) {} }