use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.
the class DistributedSystem method createTables.
@Override
public void createTables(DatabaseSession session) {
SchemaManager schemaManager = new SchemaManager(session);
// Start Build fieldTypes
schemaManager.buildFieldTypes(Dist_Employee.tableDefinition());
schemaManager.buildFieldTypes(Company.tableDefinition());
schemaManager.buildFieldTypes(Item.tableDefinition());
// start drop constraints
try {
schemaManager.dropConstraints(Dist_Employee.tableDefinition());
schemaManager.dropConstraints(Company.tableDefinition());
schemaManager.dropConstraints(Item.tableDefinition());
} catch (org.eclipse.persistence.exceptions.DatabaseException dbE) {
// ignore
}
// end drop constraints
// start replace tables
schemaManager.replaceObject(Dist_Employee.tableDefinition());
schemaManager.replaceObject(Company.tableDefinition());
schemaManager.replaceObject(Item.tableDefinition());
// end replace tables
// start create constraints
schemaManager.createConstraints(Dist_Employee.tableDefinition());
schemaManager.createConstraints(Company.tableDefinition());
schemaManager.createConstraints(Item.tableDefinition());
// end create constraints
schemaManager.createSequences();
}
use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.
the class SubstituteSequencingWithReturningPolicyAdapter method createSequences.
public void createSequences(Session session) {
if (!session.getPlatform().supportsSequenceObjects()) {
throw new TestWarningException("Requires database platform that supports sequence objects (like Oracle) - they will be used by triggers");
}
SchemaManager schemaManager = new SchemaManager((DatabaseSession) session);
Hashtable sequenceNameToDefinition = new Hashtable();
Enumeration tableNames = tableToField.keys();
while (tableNames.hasMoreElements()) {
String tableName = (String) tableNames.nextElement();
String sequenceName = getSequenceNameFromTableName(tableName);
if (!sequenceNameToDefinition.containsKey(sequenceName)) {
SequenceObjectDefinition definition = new SequenceObjectDefinition(new NativeSequence(sequenceName, 1, false));
sequenceNameToDefinition.put(sequenceName, definition);
schemaManager.createObject(definition);
}
}
}
use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.
the class RMISessionBrokerRemoteModel method createTables.
public void createTables() {
SessionBroker broker = new SessionBroker();
DatabaseSession session1 = new DatabaseSessionImpl(Server.getLogin1());
DatabaseSession session2 = new DatabaseSessionImpl(Server.getLogin2());
session1.addDescriptors(new EmployeeProject1());
session2.addDescriptors(new EmployeeProject2());
broker.registerSession("broker1", session1);
broker.registerSession("broker2", session2);
broker.setLogLevel(getSession().getLogLevel());
broker.setLog(getSession().getLog());
broker.login();
// Set session for join table.
((ManyToManyMapping) session1.getDescriptor(Employee.class).getObjectBuilder().getMappingForAttributeName("projects")).setSessionName("broker2");
// Disable delete verify.
((OneToOneMapping) session1.getDescriptor(Employee.class).getObjectBuilder().getMappingForAttributeName("address")).setShouldVerifyDelete(false);
org.eclipse.persistence.testing.models.employee.relational.EmployeeTableCreator tables = new org.eclipse.persistence.testing.models.employee.relational.EmployeeTableCreator();
tables.replaceTables(session1);
tables.replaceTables(session2);
tables.dropConstraints(session1);
tables.dropConstraints(session2);
new SchemaManager(session1).createSequences();
new SchemaManager(session2).createSequences();
broker.logout();
}
use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.
the class ReadOnlySystem method createTables.
@Override
public void createTables(DatabaseSession session) {
SchemaManager schemaManager = new SchemaManager(session);
schemaManager.replaceObject(Promoter.tableDefinition());
schemaManager.replaceObject(Actor.tableDefinition());
schemaManager.replaceObject(Actor.actorMovieJoinTableDefinition());
schemaManager.replaceObject(Actor.actorCharityJoinTableDefinition());
schemaManager.replaceObject(Address.tableDefinition());
schemaManager.replaceObject(Charity.tableDefinition());
schemaManager.replaceObject(HollywoodAgent.tableDefinition());
schemaManager.replaceObject(Movie.tableDefinition());
schemaManager.replaceObject(Country.tableDefinition());
// schemaManager.replaceObject(PhoneNumber.tableDefinition());
schemaManager.replaceObject(DefaultReadOnlyTestClass.tableDefinition());
schemaManager.createSequences();
}
use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.
the class EmployeePopulator method persistExample.
public void persistExample(Session session) {
Vector allObjects = new Vector();
UnitOfWork unitOfWork = session.acquireUnitOfWork();
// Disable the read-only classes for model population. Specifically,
// in this case we want to be able to create EquipmentCode objects.
unitOfWork.removeAllReadOnlyClasses();
PopulationManager.getDefaultManager().addAllObjectsForClass(Employee.class, allObjects);
PopulationManager.getDefaultManager().addAllObjectsForClass(SmallProject.class, allObjects);
PopulationManager.getDefaultManager().addAllObjectsForClass(LargeProject.class, allObjects);
PopulationManager.getDefaultManager().addAllObjectsForClass(GoldBuyer.class, allObjects);
PopulationManager.getDefaultManager().addAllObjectsForClass(PlatinumBuyer.class, allObjects);
PopulationManager.getDefaultManager().addAllObjectsForClass(EquipmentCode.class, allObjects);
PopulationManager.getDefaultManager().addAllObjectsForClass(MyTestEntity.class, allObjects);
unitOfWork.registerAllObjects(allObjects);
unitOfWork.commit();
if (TestCase.supportsStoredProcedures(session)) {
boolean orig_FAST_TABLE_CREATOR = SchemaManager.FAST_TABLE_CREATOR;
// of an instance of this class (drops & re-)creates the tables.
if (useFastTableCreatorAfterInitialCreate && !isFirstCreation) {
SchemaManager.FAST_TABLE_CREATOR = true;
}
try {
SchemaManager schema = new SchemaManager((DatabaseSession) session);
schema.replaceObject(buildOracleStoredProcedureReadFromAddress((DatabaseSession) session));
schema.replaceObject(buildOracleStoredProcedureReadFromEmployee((DatabaseSession) session));
schema.replaceObject(buildOracleStoredProcedureReadInOut((DatabaseSession) session));
} finally {
if (useFastTableCreatorAfterInitialCreate && !isFirstCreation) {
SchemaManager.FAST_TABLE_CREATOR = orig_FAST_TABLE_CREATOR;
}
}
// next time it deletes the rows instead.
isFirstCreation = false;
}
}
Aggregations