use of com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry in project dal by ctripcorp.
the class DaoOfDatabaseSet method deleteDatabaseSetEntryById.
/**
* 根据主键id删除entry
*
* @param id
* @return
*/
public int deleteDatabaseSetEntryById(Integer id) throws SQLException {
DatabaseSetEntry entry = new DatabaseSetEntry();
entry.setId(id);
DalHints hints = DalHints.createIfAbsent(null);
return client2.delete(hints, entry);
}
use of com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry in project dal by ctripcorp.
the class DaoOfDatabaseSet method getMasterDatabaseSetEntryByDatabaseSetName.
public DatabaseSetEntry getMasterDatabaseSetEntryByDatabaseSetName(String dbName) throws SQLException {
FreeSelectSqlBuilder<DatabaseSetEntry> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT en.id, en.name, en.databaseType, en.sharding, en.connectionString, en.databaseSet_Id, en.update_user_no, en.update_time " + "FROM databasesetentry as en join databaseset as se on en.databaseSet_Id = se.id " + "WHERE se.name = ? and en.databaseType = 'Master' limit 1");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.set(i++, "name", Types.VARCHAR, dbName);
builder.mapWith(databaseSetEntryRowMapper).requireFirst().nullable();
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
DatabaseSetEntry entry = queryDao.query(builder, parameters, hints);
processDatabaseSetEntry(entry);
return entry;
}
use of com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry in project dal by ctripcorp.
the class AllInOneNameUtilsTest method getAllInOneNameByNameOnlyTest.
@Test
public void getAllInOneNameByNameOnlyTest() throws SQLException {
String dbname = "abtest_dalcluster";
assertEquals(dbname, AllInOneNameUtils.getAllInOneNameByNameOnly(dbname));
PowerMockito.mockStatic(BeanGetter.class);
PowerMockito.when(BeanGetter.getDaoOfDatabaseSet()).thenReturn(daoOfDatabaseSet);
DatabaseSetEntry databaseSetEntry = new DatabaseSetEntry();
databaseSetEntry.setConnectionString("connection");
Mockito.when(daoOfDatabaseSet.getMasterDatabaseSetEntryByDatabaseSetName("titankey")).thenReturn(databaseSetEntry);
assertEquals("connection", AllInOneNameUtils.getAllInOneNameByNameOnly("titankey"));
}
use of com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry in project dal by ctripcorp.
the class AllInOneNameUtilsTest method getAllInOneNameTest.
@Test
public void getAllInOneNameTest() throws SQLException {
String dbname = "abtest_dalcluster";
assertEquals(dbname, AllInOneNameUtils.getAllInOneName(dbname, "dalcluster"));
PowerMockito.mockStatic(BeanGetter.class);
PowerMockito.when(BeanGetter.getDaoOfDatabaseSet()).thenReturn(daoOfDatabaseSet);
DatabaseSetEntry databaseSetEntry = new DatabaseSetEntry();
databaseSetEntry.setConnectionString("connection");
Mockito.when(daoOfDatabaseSet.getMasterDatabaseSetEntryByDatabaseSetName(dbname)).thenReturn(databaseSetEntry);
assertEquals("connection", AllInOneNameUtils.getAllInOneName(dbname, "titankey"));
}
Aggregations