use of org.apache.cayenne.access.DataNode in project cayenne by apache.
the class BatchActionIT method testHasGeneratedKeys2.
@Test
public void testHasGeneratedKeys2() throws Exception {
EntityResolver resolver = runtime.getChannel().getEntityResolver();
// test with adapter that does not support keys...
JdbcAdapter adapter = buildAdapter(false);
DataNode node = new DataNode();
node.setAdapter(adapter);
node.setEntityResolver(resolver);
node.setRowReaderFactory(mock(RowReaderFactory.class));
InsertBatchQuery batch2 = new InsertBatchQuery(resolver.getObjEntity(Artist.class).getDbEntity(), 5);
assertFalse(new BatchAction(batch2, node, false).hasGeneratedKeys());
}
use of org.apache.cayenne.access.DataNode in project cayenne by apache.
the class SchemaBuilder method initNode.
private void initNode(DataMap map) throws Exception {
DataNode node = new DataNode(map.getName());
node.setJdbcEventLogger(jdbcEventLogger);
node.setAdapter(dbAdapter);
node.setDataSource(dataSourceFactory.getSharedDataSource());
// setup test extended types
node.getAdapter().getExtendedTypes().registerType(new StringET1ExtendedType());
// tweak mapping with a delegate
for (Procedure proc : map.getProcedures()) {
unitDbAdapter.tweakProcedure(proc);
}
filterDataMap(map);
node.addDataMap(map);
node.setSchemaUpdateStrategy(new SkipSchemaUpdateStrategy());
node.setRowReaderFactory(new DefaultRowReaderFactory());
node.setBatchTranslatorFactory(new DefaultBatchTranslatorFactory());
node.setSelectTranslatorFactory(new DefaultSelectTranslatorFactory());
domain.addNode(node);
}
use of org.apache.cayenne.access.DataNode in project cayenne by apache.
the class ServerCaseDataNodeFactory method createDataNode.
@Override
public DataNode createDataNode(DataNodeDescriptor nodeDescriptor) throws Exception {
DataNode dataNode = new DataNode(nodeDescriptor.getName());
dataNode.setJdbcEventLogger(jdbcEventLogger);
dataNode.setRowReaderFactory(rowReaderFactory);
dataNode.setBatchTranslatorFactory(batchTranslatorFactory);
dataNode.setSelectTranslatorFactory(selectTranslatorFactory);
// shared or dedicated DataSources can be mapped per DataMap
dataNode.setDataSource(dataSourceFactory.getDataSource(nodeDescriptor.getName()));
dataNode.setAdapter(adapter);
dataNode.setSchemaUpdateStrategy(new SkipSchemaUpdateStrategy());
dataNode.setSqlTemplateProcessor(sqlTemplateProcessor);
return dataNode;
}
use of org.apache.cayenne.access.DataNode in project cayenne by apache.
the class DataDomainProvider method addDataNode.
/**
* @since 4.0
*/
protected DataNode addDataNode(DataDomain dataDomain, DataNodeDescriptor nodeDescriptor) throws Exception {
DataNode dataNode = dataNodeFactory.createDataNode(nodeDescriptor);
// DataMaps
for (String dataMapName : nodeDescriptor.getDataMapNames()) {
dataNode.addDataMap(dataDomain.getDataMap(dataMapName));
}
dataDomain.addNode(dataNode);
return dataNode;
}
use of org.apache.cayenne.access.DataNode in project cayenne by apache.
the class DataDomainProvider method createAndInitDataDomain.
protected DataDomain createAndInitDataDomain() throws Exception {
DataChannelDescriptor descriptor = loadDescriptor();
DataDomain dataDomain = createDataDomain(descriptor.getName());
dataDomain.setMaxIdQualifierSize(runtimeProperties.getInt(Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY, -1));
dataDomain.setQueryCache(new NestedQueryCache(queryCache));
dataDomain.setEntitySorter(injector.getInstance(EntitySorter.class));
dataDomain.setEventManager(injector.getInstance(EventManager.class));
dataDomain.setDataRowStoreFactory(injector.getInstance(DataRowStoreFactory.class));
dataDomain.initWithProperties(descriptor.getProperties());
for (DataMap dataMap : descriptor.getDataMaps()) {
dataDomain.addDataMap(dataMap);
}
dataDomain.getEntityResolver().applyDBLayerDefaults();
dataDomain.getEntityResolver().setValueObjectTypeRegistry(valueObjectTypeRegistry);
for (DataNodeDescriptor nodeDescriptor : descriptor.getNodeDescriptors()) {
addDataNode(dataDomain, nodeDescriptor);
}
// init default node
DataNode defaultNode = null;
if (descriptor.getDefaultNodeName() != null) {
defaultNode = dataDomain.getDataNode(descriptor.getDefaultNodeName());
}
if (defaultNode == null) {
Collection<DataNode> allNodes = dataDomain.getDataNodes();
if (allNodes.size() == 1) {
defaultNode = allNodes.iterator().next();
}
}
if (defaultNode != null) {
logger.info("setting DataNode '" + defaultNode.getName() + "' as default, used by all unlinked DataMaps");
dataDomain.setDefaultNode(defaultNode);
}
for (DataChannelFilter filter : filters) {
dataDomain.addFilter(filter);
}
for (Object listener : listeners) {
dataDomain.addListener(listener);
}
return dataDomain;
}
Aggregations