use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.
the class EmployeeProjectTestSuite method setUp.
@BeforeClass
public static void setUp() {
DynamicClassLoader dcl = new DynamicClassLoader(EmployeeProjectTestSuite.class.getClassLoader());
Project project = null;
try {
project = DynamicTypeBuilder.loadDynamicProject(PROJECT_XML, createLogin(), dcl);
} catch (IOException e) {
// e.printStackTrace();
fail("cannot find employee-project.xml");
}
session = project.createDatabaseSession();
if (SessionLog.OFF == logLevel) {
session.dontLogMessages();
} else {
session.setLogLevel(logLevel);
}
dynamicHelper = new DynamicHelper(session);
session.login();
new SchemaManager(session).replaceDefaultTables();
}
use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.
the class EntityTypeFromScratch method entityTypeFromDescriptor.
@Test
public void entityTypeFromDescriptor() throws Exception {
DynamicType entityType = buildMyEntityType();
assertEquals(MyEntity.class, entityType.getJavaClass());
DatabaseSession session = createSession();
session.login();
session.addDescriptor(entityType.getDescriptor());
new SchemaManager(session).replaceDefaultTables();
DynamicEntity entity = entityType.newDynamicEntity();
entity.set("id", 1);
entity.set("name", "Name");
session.insertObject(entity);
session.logout();
}
use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.
the class BrokerTestModel method buildBroker.
/**
* Build the session broker, this assume two data-sources Broker1 and Broker2 (JConnect).
*/
public SessionBroker buildBroker() {
SessionBroker broker = new SessionBroker();
DatabaseSession session1 = new DatabaseSessionImpl(getLogin1());
DatabaseSession session2 = new DatabaseSessionImpl(getLogin2());
session1.addDescriptors(new EmployeeProject1());
session2.addDescriptors(new EmployeeProject2());
broker.registerSession("broker1", session1);
broker.registerSession("broker2", session2);
broker.setSessionLog(oldSession.getSessionLog());
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();
new org.eclipse.persistence.testing.models.employee.relational.EmployeeSystem().populate(broker);
return broker;
}
use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.
the class ServerBrokerTestModel method createTables.
/**
* Create the tables on both databases.
*/
public void createTables() {
SessionBroker broker = new SessionBroker();
DatabaseSession session1 = new DatabaseSessionImpl(getLogin1());
DatabaseSession session2 = new DatabaseSessionImpl(getLogin2());
session1.addDescriptors(new EmployeeProject1());
session2.addDescriptors(new EmployeeProject2());
broker.registerSession("broker1", session1);
broker.registerSession("broker2", session2);
broker.setLog(oldSession.getLog());
broker.setLogLevel(oldSession.getLogLevel());
broker.login();
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 AutoTableGeneratorEmployeeSystem method createTables.
/**
* Drop tables/constraints, and then create default tables via schema
* manager
*/
@Override
public void createTables(DatabaseSession session) {
boolean orig_FAST_TABLE_CREATOR = SchemaManager.FAST_TABLE_CREATOR;
// on Symfoware, to avoid table locking issues, don't drop old tables
if (useFastTableCreatorAfterInitialCreate) {
SchemaManager.FAST_TABLE_CREATOR = true;
}
try {
dropTableConstraints(session);
// drop tables and then create 'default' tables.
new SchemaManager(session).replaceDefaultTables();
} finally {
if (useFastTableCreatorAfterInitialCreate) {
SchemaManager.FAST_TABLE_CREATOR = orig_FAST_TABLE_CREATOR;
}
}
}
Aggregations