use of org.apache.cayenne.map.DbKeyGenerator in project cayenne by apache.
the class JdbcAdapterIT method testCreateTableQuoteSqlIdentifiers.
@Test
public void testCreateTableQuoteSqlIdentifiers() {
if (dbAdapter instanceof MySQLAdapter) {
DbEntity entity = new DbEntity();
DbAttribute attr = new DbAttribute();
attr.setName("name column");
attr.setType(1);
entity.addAttribute(attr);
DbKeyGenerator id = new DbKeyGenerator();
entity.setPrimaryKeyGenerator(id);
DataMap dm = new DataMap();
dm.setQuotingSQLIdentifiers(true);
entity.setDataMap(dm);
entity.setName("name table");
MySQLAdapter adaptMySQL = (MySQLAdapter) dbAdapter;
String str = "CREATE TABLE `name table` (`name column` CHAR NULL) ENGINE=InnoDB";
assertEquals(str, adaptMySQL.createTable(entity));
}
}
use of org.apache.cayenne.map.DbKeyGenerator in project cayenne by apache.
the class OraclePkGeneratorIT method testSequenceNameCustom2.
@Test
public void testSequenceNameCustom2() throws Exception {
DbEntity entity = new DbEntity("TEST_ENTITY");
DbKeyGenerator customGenerator = new DbKeyGenerator();
customGenerator.setGeneratorType(DbKeyGenerator.NAMED_SEQUENCE_TABLE_TYPE);
customGenerator.setGeneratorName("CUSTOM_GENERATOR");
assertEquals("pk_test_entity", pkGenerator.sequenceName(entity));
}
use of org.apache.cayenne.map.DbKeyGenerator in project cayenne by apache.
the class DbKeyGeneratorHandler method setDbGeneratorType.
private void setDbGeneratorType(String type) {
if (entity == null) {
return;
}
DbKeyGenerator pkGenerator = entity.getPrimaryKeyGenerator();
pkGenerator.setGeneratorType(type);
if (pkGenerator.getGeneratorType() == null) {
entity.setPrimaryKeyGenerator(null);
}
}
use of org.apache.cayenne.map.DbKeyGenerator in project cayenne by apache.
the class DbKeyGeneratorHandler method setDbGeneratorName.
private void setDbGeneratorName(String name) {
if (entity == null) {
return;
}
DbKeyGenerator pkGenerator = entity.getPrimaryKeyGenerator();
if (pkGenerator == null) {
return;
}
pkGenerator.setGeneratorName(name);
}
use of org.apache.cayenne.map.DbKeyGenerator in project cayenne by apache.
the class PKCustomSequenceGeneratorPanel method setPKName.
protected void setPKName(String text) {
if (mediator.getCurrentDbEntity() == null || mediator.getCurrentDbEntity().getPrimaryKeyGenerator() == null) {
return;
}
if (text != null && text.trim().length() == 0) {
text = null;
}
DbKeyGenerator generator = mediator.getCurrentDbEntity().getPrimaryKeyGenerator();
if (!Util.nullSafeEquals(text, generator.getName())) {
generator.setGeneratorName(text);
mediator.fireDbEntityEvent(new EntityEvent(this, generator.getDbEntity()));
}
}
Aggregations