/** * Checks if the ConnectionInfo with the specified name is available. * @param name Name of the ConnectionInfo * @return True if the ConnectionInfo exists, false otherwise */ public boolean hasConnectionInfo(String name) { for (ConnectionInfo connectionInfo : getAvailableConnectionInfos()) { if (connectionInfo.getName().equals(name)) return true; } return false; } }
@Override public String toString() { return JuStringUtils.toString(DbPersistenceStorage.class, "connectionName", this.connectionInfo.getName()); } }
@Override public String getName() { return this.getConnectionInfo().getName(); }
@Override public String toString() { return JuStringUtils.toString(this, "connectionInfoName", this.connectionInfo == null ? null : ObjectUtils.toString(this.connectionInfo.getName())); } }
@Override public int compareTo(ConnectionInfo o) { return ObjectUtils.compare(this.getName(), o == null ? null : o.getName()); }
@Override public int compareTo(ConnectionInfo o) { return ObjectUtils.compare(this.getName(), o == null ? null : o.getName()); }
/** * Sets the ConnectionInfo to be used by its name. If it doesn't exist, a * runtime exception is thrown * <p> * If we set the ConnectionInfo within a transaction, it will be applied to the next * Transaction that is started - or to any database interaction without a transaction. * @param connectionInfoName New ConnectionInfo name */ public void setConnectionInfoByName(String connectionInfoName) { for (ConnectionInfo connectionInfo : availableConnectionInfos) { if (connectionInfoName.equals(connectionInfo.getName())) { setConnectionInfo(connectionInfo); return; } } throw new JuDbException("No ConnectionInfo available by the name " + connectionInfoName); }
this.setUniqueName(connectionInfo.getName());
@Test public void dbConnection() { Assert.assertEquals("Derby Test DB", this.connectionInfo.getName()); Assert.assertNull(this.connectionInfo.getSchema()); CustomObject o = new CustomObject(); this.entityManager.persist(o); Assert.assertNotNull(o.getId()); }