Search in sources :

Example 1 with DatabaseSessionImpl

use of org.eclipse.persistence.internal.sessions.DatabaseSessionImpl in project eclipselink by eclipse-ee4j.

the class RCMDistributedServer method run.

/**
 * This method starts the server and makes the dispatcher available
 * Creation date: (7/21/00 9:58:37 AM)
 */
@Override
public void run() {
    RemoteCommandManager cm = new RemoteCommandManager((AbstractSession) session);
    // set propagate command synchronously for testing
    cm.setShouldPropagateAsynchronously(false);
    cm.getDiscoveryManager().setAnnouncementDelay(0);
    // ovewrite default to use RMI registry naming service
    cm.getTransportManager().setNamingServiceType(TransportManager.REGISTRY_NAMING_SERVICE);
    // set full rmi URL of local host
    cm.setUrl("rmi://localhost:1099");
    // turn on cache sync with RCM
    ((AbstractSession) session).setShouldPropagateChanges(true);
    cm.setServerPlatform(new NoServerPlatform(new DatabaseSessionImpl()));
    cm.initialize();
}
Also used : DatabaseSessionImpl(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl) RemoteCommandManager(org.eclipse.persistence.sessions.coordination.RemoteCommandManager) NoServerPlatform(org.eclipse.persistence.platform.server.NoServerPlatform) AbstractSession(org.eclipse.persistence.internal.sessions.AbstractSession)

Example 2 with DatabaseSessionImpl

use of org.eclipse.persistence.internal.sessions.DatabaseSessionImpl 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 DatabaseSessionImpl

use of org.eclipse.persistence.internal.sessions.DatabaseSessionImpl 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)

Example 4 with DatabaseSessionImpl

use of org.eclipse.persistence.internal.sessions.DatabaseSessionImpl 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;
}
Also used : ManyToManyMapping(org.eclipse.persistence.mappings.ManyToManyMapping) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) SessionBroker(org.eclipse.persistence.sessions.broker.SessionBroker) SchemaManager(org.eclipse.persistence.tools.schemaframework.SchemaManager) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) DatabaseSessionImpl(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping)

Example 5 with DatabaseSessionImpl

use of org.eclipse.persistence.internal.sessions.DatabaseSessionImpl in project eclipselink by eclipse-ee4j.

the class SQLStatement method toString.

/**
 * Try to print the SQL.
 */
@Override
public String toString() {
    StringWriter writer = new StringWriter();
    writer.write(Helper.getShortClassName(getClass()));
    writer.write("(");
    try {
        DatabaseCall call = buildCall(new DatabaseSessionImpl(new org.eclipse.persistence.sessions.DatabaseLogin()));
        writer.write(call.getSQLString());
    } catch (Exception exception) {
    }
    writer.write(")");
    return writer.toString();
}
Also used : DatabaseCall(org.eclipse.persistence.internal.databaseaccess.DatabaseCall) DatabaseSessionImpl(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl)

Aggregations

DatabaseSessionImpl (org.eclipse.persistence.internal.sessions.DatabaseSessionImpl)64 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)18 EntityManager (jakarta.persistence.EntityManager)15 HashMap (java.util.HashMap)14 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)14 Map (java.util.Map)13 DatabaseLogin (org.eclipse.persistence.sessions.DatabaseLogin)13 Project (org.eclipse.persistence.sessions.Project)12 StringReader (java.io.StringReader)9 StreamSource (javax.xml.transform.stream.StreamSource)9 Platform (org.eclipse.persistence.internal.databaseaccess.Platform)9 MetadataProcessor (org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor)9 AbstractSession (org.eclipse.persistence.internal.sessions.AbstractSession)9 XMLContext (org.eclipse.persistence.oxm.XMLContext)9 DatasourceLogin (org.eclipse.persistence.sessions.DatasourceLogin)9 JAXBContext (jakarta.xml.bind.JAXBContext)8 JAXBException (jakarta.xml.bind.JAXBException)8 Unmarshaller (jakarta.xml.bind.Unmarshaller)8 ConversionManager (org.eclipse.persistence.internal.helper.ConversionManager)8 XRDynamicClassLoader (org.eclipse.persistence.internal.xr.XRDynamicClassLoader)8