Search in sources :

Example 1 with SessionBroker

use of org.eclipse.persistence.sessions.broker.SessionBroker in project eclipselink by eclipse-ee4j.

the class ExternalTransactionControllerInitializationTest method test.

@Override
public void test() {
    broker = new SessionBroker();
    CustomServerPlatform platform = new CustomServerPlatform(broker);
    platform.setExternalTransactionControllerClass(JTATransactionController.class);
    broker.setServerPlatform(platform);
    broker.setSessionLog(getSession().getSessionLog());
    broker.login();
}
Also used : CustomServerPlatform(org.eclipse.persistence.platform.server.CustomServerPlatform) SessionBroker(org.eclipse.persistence.sessions.broker.SessionBroker)

Example 2 with SessionBroker

use of org.eclipse.persistence.sessions.broker.SessionBroker in project eclipselink by eclipse-ee4j.

the class MultipleClientBrokersTestModel method createTables.

/**
 * This method was created in VisualAge.
 */
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 org.eclipse.persistence.tools.schemaframework.SchemaManager(session1).createSequences();
    new org.eclipse.persistence.tools.schemaframework.SchemaManager(session2).createSequences();
    new EmployeeSystem().populate(broker);
    broker.logout();
}
Also used : ManyToManyMapping(org.eclipse.persistence.mappings.ManyToManyMapping) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) SessionBroker(org.eclipse.persistence.sessions.broker.SessionBroker) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) DatabaseSessionImpl(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping) EmployeeSystem(org.eclipse.persistence.testing.models.employee.relational.EmployeeSystem)

Example 3 with SessionBroker

use of org.eclipse.persistence.sessions.broker.SessionBroker in project eclipselink by eclipse-ee4j.

the class ReadOnlyClassesInSessionBrokerTest method setup.

@Override
public void setup() {
    ServerSession serverSession;
    Project project = new org.eclipse.persistence.testing.models.readonly.ReadOnlyProject();
    DatabaseLogin login = project.getLogin();
    login.usePlatform(new OraclePlatform());
    login.setDriverClassName("oracle.jdbc.OracleDriver");
    login.setConnectionString("jdbc:oracle:thin:@ottvm028.ca.oracle.com:1521:toplink");
    login.setUserName("QA6");
    login.setPassword("password");
    serverSession = (ServerSession) project.createServerSession();
    this.sessionBroker = new SessionBroker();
    this.sessionBroker.registerSession("broker1", serverSession);
    this.sessionBroker.login();
}
Also used : Project(org.eclipse.persistence.sessions.Project) DatabaseLogin(org.eclipse.persistence.sessions.DatabaseLogin) ServerSession(org.eclipse.persistence.sessions.server.ServerSession) SessionBroker(org.eclipse.persistence.sessions.broker.SessionBroker) OraclePlatform(org.eclipse.persistence.platform.database.OraclePlatform)

Example 4 with SessionBroker

use of org.eclipse.persistence.sessions.broker.SessionBroker in project eclipselink by eclipse-ee4j.

the class ServerBrokerTestModel method buildBroker.

/**
 * Build the session broker, this assume two data-sources Broker1 and Broker2 (JConnect).
 */
public SessionBroker buildBroker() {
    createTables();
    SessionBroker broker = new SessionBroker();
    addQuery1(broker);
    addQuery2(broker);
    ServerSession ssession1 = new ServerSession(getLogin1());
    ServerSession ssession2 = new ServerSession(getLogin2());
    ssession1.addDescriptors(new EmployeeProject1());
    ssession2.addDescriptors(new EmployeeProject2());
    broker.registerSession("broker1", ssession1);
    broker.registerSession("broker2", ssession2);
    broker.setLog(oldSession.getLog());
    broker.setLogLevel(oldSession.getLogLevel());
    broker.login();
    // Set session for join table.
    ((ManyToManyMapping) ssession1.getDescriptor(Employee.class).getObjectBuilder().getMappingForAttributeName("projects")).setSessionName("broker2");
    // Disable delete verify.
    ((OneToOneMapping) ssession1.getDescriptor(Employee.class).getObjectBuilder().getMappingForAttributeName("address")).setShouldVerifyDelete(false);
    SessionBroker clientBroker = broker.acquireClientSessionBroker();
    new org.eclipse.persistence.testing.models.employee.relational.EmployeeSystem().populate(clientBroker);
    return clientBroker;
}
Also used : ManyToManyMapping(org.eclipse.persistence.mappings.ManyToManyMapping) ServerSession(org.eclipse.persistence.sessions.server.ServerSession) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) SessionBroker(org.eclipse.persistence.sessions.broker.SessionBroker) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping)

Example 5 with SessionBroker

use of org.eclipse.persistence.sessions.broker.SessionBroker 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();
}
Also used : DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) SessionBroker(org.eclipse.persistence.sessions.broker.SessionBroker) SchemaManager(org.eclipse.persistence.tools.schemaframework.SchemaManager) DatabaseSessionImpl(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl)

Aggregations

SessionBroker (org.eclipse.persistence.sessions.broker.SessionBroker)38 ServerSession (org.eclipse.persistence.sessions.server.ServerSession)17 EntityManager (jakarta.persistence.EntityManager)12 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)12 HashMap (java.util.HashMap)11 AbstractSession (org.eclipse.persistence.internal.sessions.AbstractSession)7 JpaEntityManagerFactory (org.eclipse.persistence.jpa.JpaEntityManagerFactory)7 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)7 Map (java.util.Map)6 DatabaseSessionImpl (org.eclipse.persistence.internal.sessions.DatabaseSessionImpl)6 OptimisticLockException (jakarta.persistence.OptimisticLockException)5 PersistenceException (jakarta.persistence.PersistenceException)5 EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)5 IntegrityException (org.eclipse.persistence.exceptions.IntegrityException)5 ValidationException (org.eclipse.persistence.exceptions.ValidationException)5 ManyToManyMapping (org.eclipse.persistence.mappings.ManyToManyMapping)5 OneToOneMapping (org.eclipse.persistence.mappings.OneToOneMapping)5 TestProblemException (org.eclipse.persistence.testing.framework.TestProblemException)5 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)5 Address (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_1.Address)5