本文整理汇总了Java中com.querydsl.sql.dml.SQLInsertClause.executeWithKey方法的典型用法代码示例。如果您正苦于以下问题:Java SQLInsertClause.executeWithKey方法的具体用法?Java SQLInsertClause.executeWithKey怎么用?Java SQLInsertClause.executeWithKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.querydsl.sql.dml.SQLInsertClause
的用法示例。
在下文中一共展示了SQLInsertClause.executeWithKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertFeatureOfInterest
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertFeatureOfInterest(FeatureOfInterest foi) throws NoSuchEntityException {
// No linked entities to check first.
SQLQueryFactory qFactory = pm.createQueryFactory();
QFeatures qfoi = QFeatures.features;
SQLInsertClause insert = qFactory.insert(qfoi);
insert.set(qfoi.name, foi.getName());
insert.set(qfoi.description, foi.getDescription());
insert.set(qfoi.properties, objectToJson(foi.getProperties()));
String encodingType = foi.getEncodingType();
insert.set(qfoi.encodingType, encodingType);
insertGeometry(insert, qfoi.feature, qfoi.geom, encodingType, foi.getFeature());
UUID generatedId = insert.executeWithKey(qfoi.id);
LOGGER.info("Inserted FeatureOfInterest. Created id = {}.", generatedId);
foi.setId(new UuidId(generatedId));
return true;
}
示例2: insertSensor
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertSensor(Sensor s) throws NoSuchEntityException, IncompleteEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QSensors qs = QSensors.sensors;
SQLInsertClause insert = qFactory.insert(qs);
insert.set(qs.name, s.getName());
insert.set(qs.description, s.getDescription());
insert.set(qs.encodingType, s.getEncodingType());
// TODO: Check metadata serialisation.
insert.set(qs.metadata, s.getMetadata().toString());
insert.set(qs.properties, objectToJson(s.getProperties()));
String generatedId = insert.executeWithKey(qs.id);
LOGGER.info("Inserted Sensor. Created id = {}.", generatedId);
s.setId(new StringId(generatedId));
// Create new datastreams, if any.
for (Datastream ds : s.getDatastreams()) {
ds.setSensor(new SensorBuilder().setId(s.getId()).build());
ds.complete();
pm.insert(ds);
}
return true;
}
示例3: insertFeatureOfInterest
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertFeatureOfInterest(FeatureOfInterest foi) throws NoSuchEntityException {
// No linked entities to check first.
SQLQueryFactory qFactory = pm.createQueryFactory();
QFeatures qfoi = QFeatures.features;
SQLInsertClause insert = qFactory.insert(qfoi);
insert.set(qfoi.name, foi.getName());
insert.set(qfoi.description, foi.getDescription());
insert.set(qfoi.properties, objectToJson(foi.getProperties()));
String encodingType = foi.getEncodingType();
insert.set(qfoi.encodingType, encodingType);
insertGeometry(insert, qfoi.feature, qfoi.geom, encodingType, foi.getFeature());
Long generatedId = insert.executeWithKey(qfoi.id);
LOGGER.info("Inserted FeatureOfInterest. Created id = {}.", generatedId);
foi.setId(new LongId(generatedId));
return true;
}
示例4: insertSensor
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertSensor(Sensor s) throws NoSuchEntityException, IncompleteEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QSensors qs = QSensors.sensors;
SQLInsertClause insert = qFactory.insert(qs);
insert.set(qs.name, s.getName());
insert.set(qs.description, s.getDescription());
insert.set(qs.encodingType, s.getEncodingType());
// TODO: Check metadata serialisation.
insert.set(qs.metadata, s.getMetadata().toString());
insert.set(qs.properties, objectToJson(s.getProperties()));
Long generatedId = insert.executeWithKey(qs.id);
LOGGER.info("Inserted Sensor. Created id = {}.", generatedId);
s.setId(new LongId(generatedId));
// Create new datastreams, if any.
for (Datastream ds : s.getDatastreams()) {
ds.setSensor(new SensorBuilder().setId(s.getId()).build());
ds.complete();
pm.insert(ds);
}
return true;
}
示例5: insertFeatureOfInterest
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertFeatureOfInterest(FeatureOfInterest foi) throws NoSuchEntityException {
// No linked entities to check first.
SQLQueryFactory qFactory = pm.createQueryFactory();
QFeatures qfoi = QFeatures.features;
SQLInsertClause insert = qFactory.insert(qfoi);
insert.set(qfoi.name, foi.getName());
insert.set(qfoi.description, foi.getDescription());
insert.set(qfoi.properties, objectToJson(foi.getProperties()));
String encodingType = foi.getEncodingType();
insert.set(qfoi.encodingType, encodingType);
insertGeometry(insert, qfoi.feature, qfoi.geom, encodingType, foi.getFeature());
String generatedId = insert.executeWithKey(qfoi.id);
LOGGER.info("Inserted FeatureOfInterest. Created id = {}.", generatedId);
foi.setId(new StringId(generatedId));
return true;
}
示例6: insertHistoricalLocation
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertHistoricalLocation(HistoricalLocation h) throws NoSuchEntityException, IncompleteEntityException {
Thing t = h.getThing();
entityExistsOrCreate(t);
SQLQueryFactory qFactory = pm.createQueryFactory();
QHistLocations qhl = QHistLocations.histLocations;
SQLInsertClause insert = qFactory.insert(qhl);
insert.set(qhl.time, new Timestamp(h.getTime().getDateTime().getMillis()));
insert.set(qhl.thingId, (UUID) h.getThing().getId().getValue());
UUID generatedId = insert.executeWithKey(qhl.id);
LOGGER.info("Inserted HistoricalLocation. Created id = {}.", generatedId);
h.setId(new UuidId(generatedId));
EntitySet<Location> locations = h.getLocations();
for (Location l : locations) {
entityExistsOrCreate(l);
UUID lId = (UUID) l.getId().getValue();
QLocationsHistLocations qlhl = QLocationsHistLocations.locationsHistLocations;
insert = qFactory.insert(qlhl);
insert.set(qlhl.histLocationId, generatedId);
insert.set(qlhl.locationId, lId);
insert.execute();
LOGGER.debug("Linked Location {} to HistoricalLocation {}.", lId, generatedId);
}
return true;
}
示例7: insertObservedProperty
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertObservedProperty(ObservedProperty op) throws NoSuchEntityException, IncompleteEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QObsProperties qop = QObsProperties.obsProperties;
SQLInsertClause insert = qFactory.insert(qop);
insert.set(qop.definition, op.getDefinition());
insert.set(qop.name, op.getName());
insert.set(qop.description, op.getDescription());
insert.set(qop.properties, objectToJson(op.getProperties()));
UUID generatedId = insert.executeWithKey(qop.id);
LOGGER.info("Inserted ObservedProperty. Created id = {}.", generatedId);
op.setId(new UuidId(generatedId));
return true;
}
示例8: insertObservedProperty
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertObservedProperty(ObservedProperty op) throws NoSuchEntityException, IncompleteEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QObsProperties qop = QObsProperties.obsProperties;
SQLInsertClause insert = qFactory.insert(qop);
insert.set(qop.definition, op.getDefinition());
insert.set(qop.name, op.getName());
insert.set(qop.description, op.getDescription());
insert.set(qop.properties, objectToJson(op.getProperties()));
String generatedId = insert.executeWithKey(qop.id);
LOGGER.info("Inserted ObservedProperty. Created id = {}.", generatedId);
op.setId(new StringId(generatedId));
return true;
}
示例9: insertHistoricalLocation
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertHistoricalLocation(HistoricalLocation h) throws NoSuchEntityException, IncompleteEntityException {
Thing t = h.getThing();
entityExistsOrCreate(t);
SQLQueryFactory qFactory = pm.createQueryFactory();
QHistLocations qhl = QHistLocations.histLocations;
SQLInsertClause insert = qFactory.insert(qhl);
insert.set(qhl.time, new Timestamp(h.getTime().getDateTime().getMillis()));
insert.set(qhl.thingId, (Long) h.getThing().getId().getValue());
Long generatedId = insert.executeWithKey(qhl.id);
LOGGER.info("Inserted HistoricalLocation. Created id = {}.", generatedId);
h.setId(new LongId(generatedId));
EntitySet<Location> locations = h.getLocations();
for (Location l : locations) {
entityExistsOrCreate(l);
Long lId = (Long) l.getId().getValue();
QLocationsHistLocations qlhl = QLocationsHistLocations.locationsHistLocations;
insert = qFactory.insert(qlhl);
insert.set(qlhl.histLocationId, generatedId);
insert.set(qlhl.locationId, lId);
insert.execute();
LOGGER.debug("Linked Location {} to HistoricalLocation {}.", lId, generatedId);
}
return true;
}
示例10: insertObservedProperty
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertObservedProperty(ObservedProperty op) throws NoSuchEntityException, IncompleteEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QObsProperties qop = QObsProperties.obsProperties;
SQLInsertClause insert = qFactory.insert(qop);
insert.set(qop.definition, op.getDefinition());
insert.set(qop.name, op.getName());
insert.set(qop.description, op.getDescription());
insert.set(qop.properties, objectToJson(op.getProperties()));
Long generatedId = insert.executeWithKey(qop.id);
LOGGER.info("Inserted ObservedProperty. Created id = {}.", generatedId);
op.setId(new LongId(generatedId));
return true;
}
示例11: insertHistoricalLocation
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertHistoricalLocation(HistoricalLocation h) throws NoSuchEntityException, IncompleteEntityException {
Thing t = h.getThing();
entityExistsOrCreate(t);
SQLQueryFactory qFactory = pm.createQueryFactory();
QHistLocations qhl = QHistLocations.histLocations;
SQLInsertClause insert = qFactory.insert(qhl);
insert.set(qhl.time, new Timestamp(h.getTime().getDateTime().getMillis()));
insert.set(qhl.thingId, (String) h.getThing().getId().getValue());
String generatedId = insert.executeWithKey(qhl.id);
LOGGER.info("Inserted HistoricalLocation. Created id = {}.", generatedId);
h.setId(new StringId(generatedId));
EntitySet<Location> locations = h.getLocations();
for (Location l : locations) {
entityExistsOrCreate(l);
String lId = (String) l.getId().getValue();
QLocationsHistLocations qlhl = QLocationsHistLocations.locationsHistLocations;
insert = qFactory.insert(qlhl);
insert.set(qlhl.histLocationId, generatedId);
insert.set(qlhl.locationId, lId);
insert.execute();
LOGGER.debug("Linked Location {} to HistoricalLocation {}.", lId, generatedId);
}
return true;
}
示例12: insertDatastream
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertDatastream(Datastream ds) throws NoSuchEntityException, IncompleteEntityException {
// First check ObservedPropery, Sensor and Thing
ObservedProperty op = ds.getObservedProperty();
entityExistsOrCreate(op);
Sensor s = ds.getSensor();
entityExistsOrCreate(s);
Thing t = ds.getThing();
entityExistsOrCreate(t);
SQLQueryFactory qFactory = pm.createQueryFactory();
QDatastreams qd = QDatastreams.datastreams;
SQLInsertClause insert = qFactory.insert(qd);
insert.set(qd.name, ds.getName());
insert.set(qd.description, ds.getDescription());
insert.set(qd.observationType, ds.getObservationType());
insert.set(qd.unitDefinition, ds.getUnitOfMeasurement().getDefinition());
insert.set(qd.unitName, ds.getUnitOfMeasurement().getName());
insert.set(qd.unitSymbol, ds.getUnitOfMeasurement().getSymbol());
insert.set(qd.properties, objectToJson(ds.getProperties()));
insert.set(qd.phenomenonTimeStart, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MAX.getMillis()));
insert.set(qd.phenomenonTimeEnd, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MIN.getMillis()));
insert.set(qd.resultTimeStart, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MAX.getMillis()));
insert.set(qd.resultTimeEnd, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MIN.getMillis()));
insert.set(qd.obsPropertyId, (UUID) op.getId().getValue());
insert.set(qd.sensorId, (UUID) s.getId().getValue());
insert.set(qd.thingId, (UUID) t.getId().getValue());
UUID datastreamId = insert.executeWithKey(qd.id);
LOGGER.info("Inserted datastream. Created id = {}.", datastreamId);
ds.setId(new UuidId(datastreamId));
// Create Observations, if any.
for (Observation o : ds.getObservations()) {
o.setDatastream(new DatastreamBuilder().setId(ds.getId()).build());
o.complete();
pm.insert(o);
}
return true;
}
示例13: insertMultiDatastream
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertMultiDatastream(MultiDatastream ds) throws NoSuchEntityException, IncompleteEntityException {
// First check Sensor and Thing
Sensor s = ds.getSensor();
entityExistsOrCreate(s);
Thing t = ds.getThing();
entityExistsOrCreate(t);
SQLQueryFactory qFactory = pm.createQueryFactory();
QMultiDatastreams qd = QMultiDatastreams.multiDatastreams;
SQLInsertClause insert = qFactory.insert(qd);
insert.set(qd.name, ds.getName());
insert.set(qd.description, ds.getDescription());
insert.set(qd.observationTypes, objectToJson(ds.getMultiObservationDataTypes()));
insert.set(qd.unitOfMeasurements, objectToJson(ds.getUnitOfMeasurements()));
insert.set(qd.properties, objectToJson(ds.getProperties()));
insert.set(qd.phenomenonTimeStart, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MAX.getMillis()));
insert.set(qd.phenomenonTimeEnd, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MIN.getMillis()));
insert.set(qd.resultTimeStart, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MAX.getMillis()));
insert.set(qd.resultTimeEnd, new Timestamp(PostgresPersistenceManagerUuid.DATETIME_MIN.getMillis()));
insert.set(qd.sensorId, (UUID) s.getId().getValue());
insert.set(qd.thingId, (UUID) t.getId().getValue());
UUID multiDatastreamId = insert.executeWithKey(qd.id);
LOGGER.info("Inserted multiDatastream. Created id = {}.", multiDatastreamId);
ds.setId(new UuidId(multiDatastreamId));
// Create new Locations, if any.
EntitySet<ObservedProperty> ops = ds.getObservedProperties();
int rank = 0;
for (ObservedProperty op : ops) {
entityExistsOrCreate(op);
UUID opId = (UUID) op.getId().getValue();
QMultiDatastreamsObsProperties qMdOp = QMultiDatastreamsObsProperties.multiDatastreamsObsProperties;
insert = qFactory.insert(qMdOp);
insert.set(qMdOp.multiDatastreamId, multiDatastreamId);
insert.set(qMdOp.obsPropertyId, opId);
insert.set(qMdOp.rank, rank);
insert.execute();
LOGGER.debug("Linked MultiDatastream {} to ObservedProperty {} with rank {}.", multiDatastreamId, opId, rank);
rank++;
}
// Create Observations, if any.
for (Observation o : ds.getObservations()) {
o.setMultiDatastream(new MultiDatastreamBuilder().setId(ds.getId()).build());
o.complete();
pm.insert(o);
}
return true;
}
示例14: insertThing
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertThing(Thing t) throws NoSuchEntityException, IncompleteEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QThings qt = QThings.things;
SQLInsertClause insert = qFactory.insert(qt);
insert.set(qt.name, t.getName());
insert.set(qt.description, t.getDescription());
insert.set(qt.properties, objectToJson(t.getProperties()));
UUID thingId = insert.executeWithKey(qt.id);
LOGGER.info("Inserted Thing. Created id = {}.", thingId);
t.setId(new UuidId(thingId));
// Create new Locations, if any.
List<UUID> locationIds = new ArrayList<>();
for (Location l : t.getLocations()) {
entityExistsOrCreate(l);
UUID lId = (UUID) l.getId().getValue();
QThingsLocations qtl = QThingsLocations.thingsLocations;
insert = qFactory.insert(qtl);
insert.set(qtl.thingId, thingId);
insert.set(qtl.locationId, lId);
insert.execute();
LOGGER.debug("Linked Location {} to Thing {}.", lId, thingId);
locationIds.add(lId);
}
// Now link the new locations also to a historicalLocation.
if (!locationIds.isEmpty()) {
QHistLocations qhl = QHistLocations.histLocations;
insert = qFactory.insert(qhl);
insert.set(qhl.thingId, thingId);
insert.set(qhl.time, new Timestamp(Calendar.getInstance().getTimeInMillis()));
UUID histLocationId = insert.executeWithKey(qhl.id);
LOGGER.debug("Created historicalLocation {}", histLocationId);
QLocationsHistLocations qlhl = QLocationsHistLocations.locationsHistLocations;
for (UUID locId : locationIds) {
qFactory.insert(qlhl)
.set(qlhl.histLocationId, histLocationId)
.set(qlhl.locationId, locId)
.execute();
LOGGER.info("Linked location {} to historicalLocation {}.", locId, histLocationId);
}
}
// Create new datastreams, if any.
for (Datastream ds : t.getDatastreams()) {
ds.setThing(new ThingBuilder().setId(t.getId()).build());
ds.complete();
pm.insert(ds);
}
// TODO: if we allow the creation of historicalLocations through Things
// then we have to be able to link those to Locations we might have just created.
// However, id juggling will be needed!
return true;
}
示例15: insertDatastream
import com.querydsl.sql.dml.SQLInsertClause; //导入方法依赖的package包/类
public boolean insertDatastream(Datastream ds) throws NoSuchEntityException, IncompleteEntityException {
// First check ObservedPropery, Sensor and Thing
ObservedProperty op = ds.getObservedProperty();
entityExistsOrCreate(op);
Sensor s = ds.getSensor();
entityExistsOrCreate(s);
Thing t = ds.getThing();
entityExistsOrCreate(t);
SQLQueryFactory qFactory = pm.createQueryFactory();
QDatastreams qd = QDatastreams.datastreams;
SQLInsertClause insert = qFactory.insert(qd);
insert.set(qd.name, ds.getName());
insert.set(qd.description, ds.getDescription());
insert.set(qd.observationType, ds.getObservationType());
insert.set(qd.unitDefinition, ds.getUnitOfMeasurement().getDefinition());
insert.set(qd.unitName, ds.getUnitOfMeasurement().getName());
insert.set(qd.unitSymbol, ds.getUnitOfMeasurement().getSymbol());
insert.set(qd.properties, objectToJson(ds.getProperties()));
insert.set(qd.phenomenonTimeStart, new Timestamp(PostgresPersistenceManagerLong.DATETIME_MAX.getMillis()));
insert.set(qd.phenomenonTimeEnd, new Timestamp(PostgresPersistenceManagerLong.DATETIME_MIN.getMillis()));
insert.set(qd.resultTimeStart, new Timestamp(PostgresPersistenceManagerLong.DATETIME_MAX.getMillis()));
insert.set(qd.resultTimeEnd, new Timestamp(PostgresPersistenceManagerLong.DATETIME_MIN.getMillis()));
insert.set(qd.obsPropertyId, (Long) op.getId().getValue());
insert.set(qd.sensorId, (Long) s.getId().getValue());
insert.set(qd.thingId, (Long) t.getId().getValue());
Long datastreamId = insert.executeWithKey(qd.id);
LOGGER.info("Inserted datastream. Created id = {}.", datastreamId);
ds.setId(new LongId(datastreamId));
// Create Observations, if any.
for (Observation o : ds.getObservations()) {
o.setDatastream(new DatastreamBuilder().setId(ds.getId()).build());
o.complete();
pm.insert(o);
}
return true;
}