本文整理汇总了Java中com.querydsl.sql.dml.SQLInsertClause类的典型用法代码示例。如果您正苦于以下问题:Java SQLInsertClause类的具体用法?Java SQLInsertClause怎么用?Java SQLInsertClause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLInsertClause类属于com.querydsl.sql.dml包,在下文中一共展示了SQLInsertClause类的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()));
UUID generatedId = insert.executeWithKey(qs.id);
LOGGER.info("Inserted Sensor. Created id = {}.", generatedId);
s.setId(new UuidId(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: 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;
}
示例7: saveNew
import com.querydsl.sql.dml.SQLInsertClause; //导入依赖的package包/类
private void saveNew(final Long userId, final Date startDate,
final Date endDateExcluded, final long amountInSeconds, final String description) {
transactionTemplate.execute(() -> {
return querydslSupport.execute((connection, configuration) -> {
QUserHolidayAmount qUserHolidayAmount = QUserHolidayAmount.userHolidayAmount;
long dateRangeId = new DateRangeUtil(connection, configuration).createDateRange(startDate,
endDateExcluded);
new SQLInsertClause(connection, configuration, qUserHolidayAmount)
.set(qUserHolidayAmount.userId, userId)
.set(qUserHolidayAmount.dateRangeId, dateRangeId)
.set(qUserHolidayAmount.amount, amountInSeconds)
.set(qUserHolidayAmount.description, description).execute();
return null;
});
});
}
示例8: save
import com.querydsl.sql.dml.SQLInsertClause; //导入依赖的package包/类
private void save(final long schemeId, final String userName, final Date startDate,
final Date endDateExcluded) {
transactionTemplate.execute(() -> querydslSupport.execute((connection, configuration) -> {
QCwdUser qCwdUser = QCwdUser.cwdUser;
Long userId = new SQLQuery<Long>(connection, configuration)
.select(qCwdUser.id)
.from(qCwdUser)
.where(qCwdUser.userName.eq(userName)).fetchOne();
Long dateRangeId =
new DateRangeUtil(connection, configuration).createDateRange(startDate, endDateExcluded);
new SQLInsertClause(connection, configuration,
qUserSchemeEntityParameter.userSchemeEntityPath)
.set(qUserSchemeEntityParameter.dateRangeId, dateRangeId)
.set(qUserSchemeEntityParameter.userId, userId)
.set(qUserSchemeEntityParameter.userSchemeSchemeId, schemeId).execute();
return null;
}));
}
示例9: savePublicHoliday
import com.querydsl.sql.dml.SQLInsertClause; //导入依赖的package包/类
private void savePublicHoliday(final long schemeId, final Date date, final Date replacementDate,
final String description) {
querydslSupport.execute((connection, configuration) -> {
QPublicHoliday qPublicHoliday = QPublicHoliday.publicHoliday;
SQLInsertClause insertClause = new SQLInsertClause(connection, configuration, qPublicHoliday)
.set(qPublicHoliday.date, date);
if (replacementDate != null) {
insertClause.set(qPublicHoliday.replacementDate, replacementDate);
}
if (description != null && !"".equals(description.trim())) {
insertClause.set(qPublicHoliday.description, description);
}
insertClause.set(qPublicHoliday.holidaySchemeId, schemeId);
insertClause.execute();
return null;
});
}
示例10: insertFacility
import com.querydsl.sql.dml.SQLInsertClause; //导入依赖的package包/类
@TransactionalWrite
public long insertFacility(Facility facility, long facilityId) {
checkNotNull(facility, "facility");
facility.normalize();
SQLInsertClause insert = insertFacility();
insert.set(qFacility.id, facilityId);
populate(facility, insert);
insert.execute();
insertAliases(facilityId, facility.aliases);
insertPorts(facilityId, facility.ports);
updateServices(facilityId, facility.services);
updatePaymentMethods(facilityId, facility.paymentInfo.paymentMethods);
insertPricing(facilityId, facility.pricingMethod.getPricing(facility));
insertUnavailableCapacity(facilityId, facility.unavailableCapacities);
// History updated
final DateTime currentDate = DateTime.now();
facilityHistoryRepository.updateStatusHistory(currentDate, facilityId, facility.status, facility.statusDescription);
facilityHistoryRepository.updateCapacityHistory(currentDate, facilityId, facility.builtCapacity, facility.unavailableCapacities);
return facilityId;
}
示例11: insertPricing
import com.querydsl.sql.dml.SQLInsertClause; //导入依赖的package包/类
private void insertPricing(long facilityId, List<Pricing> pricing) {
if (pricing != null && !pricing.isEmpty()) {
SQLInsertClause insert = queryFactory.insert(qPricing);
for (Pricing price : pricing) {
insert.set(qPricing.facilityId, facilityId)
.set(qPricing.capacityType, price.capacityType)
.set(qPricing.usage, price.usage)
.set(qPricing.maxCapacity, price.maxCapacity)
.set(qPricing.dayType, price.dayType)
.set(qPricing.fromTime, price.time.from)
.set(qPricing.untilTime, price.time.until);
pricingPriceMapping.populate(price.price, insert);
insert.addBatch();
}
insert.execute();
}
}
示例12: insertUtilizations
import com.querydsl.sql.dml.SQLInsertClause; //导入依赖的package包/类
@TransactionalWrite
@Override
public void insertUtilizations(List<Utilization> utilizations) {
if (utilizations.isEmpty()) {
return;
}
SQLInsertClause insertBatch = queryFactory.insert(qUtilization);
utilizations.forEach(u -> {
insertBatch.set(qUtilization.facilityId, u.facilityId);
insertBatch.set(qUtilization.capacityType, u.capacityType);
insertBatch.set(qUtilization.usage, u.usage);
insertBatch.set(qUtilization.ts, u.timestamp);
insertBatch.set(qUtilization.spacesAvailable, u.spacesAvailable);
insertBatch.set(qUtilization.capacity, u.capacity);
insertBatch.addBatch();
});
insertBatch.execute();
}
示例13: savePredictionHistory
import com.querydsl.sql.dml.SQLInsertClause; //导入依赖的package包/类
private void savePredictionHistory(Long predictorId, DateTime start, List<Prediction> predictions) {
if (predictions.isEmpty()) {
return;
}
SQLInsertClause insert = queryFactory.insert(qPredictionHistory);
predictions.forEach(p -> insert
.set(qPredictionHistory.predictorId, predictorId)
.set(qPredictionHistory.forecastDistanceInMinutes, ((int) new Duration(start, p.timestamp).getStandardMinutes()))
.set(qPredictionHistory.ts, p.timestamp)
.set(qPredictionHistory.spacesAvailable, p.spacesAvailable)
.addBatch());
try {
insert.execute();
} catch (QueryException e) {
// XXX: upsert would be a better way to ignore primary key conflicts, but this shall do for now
log.error("Failed save prediction history for predictor " + predictorId, e);
}
}
示例14: 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;
}
示例15: 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;
}