本文整理汇总了Java中com.querydsl.sql.dml.SQLUpdateClause类的典型用法代码示例。如果您正苦于以下问题:Java SQLUpdateClause类的具体用法?Java SQLUpdateClause怎么用?Java SQLUpdateClause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLUpdateClause类属于com.querydsl.sql.dml包,在下文中一共展示了SQLUpdateClause类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: update
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private void update(final Long userHolidayAmountId, final Long userId,
final Date startSqlDate, final Date endSqlDateExcluded,
final long amountInSeconds, final String description) {
transactionTemplate.execute(() -> querydslSupport.execute((connection, configuration) -> {
QUserHolidayAmount qUserHolidayAmount = QUserHolidayAmount.userHolidayAmount;
Long dateRangeId =
getDateRangeId(userHolidayAmountId, connection, configuration);
new DateRangeUtil(connection, configuration).modifyDateRange(dateRangeId, startSqlDate,
endSqlDateExcluded);
new SQLUpdateClause(connection, configuration, qUserHolidayAmount)
.set(qUserHolidayAmount.userId, userId)
.set(qUserHolidayAmount.amount, amountInSeconds)
.set(qUserHolidayAmount.description, description)
.where(qUserHolidayAmount.userHolidayAmountId.eq(userHolidayAmountId))
.execute();
return null;
}));
}
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:24,代码来源:UserHolidayAmountServlet.java
示例2: update
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private void update(final long recordId, final long schemeId, final long userId,
final Date startDate, final Date endDateExcluded) {
transactionTemplate.execute(() -> querydslSupport.execute((connection, configuration) -> {
Long dateRangeId = new SQLQuery<Long>(connection, configuration)
.select(qUserSchemeEntityParameter.dateRangeId)
.from(qUserSchemeEntityParameter.userSchemeEntityPath)
.where(qUserSchemeEntityParameter.userSchemeId.eq(recordId)).fetchOne();
new DateRangeUtil(connection, configuration).modifyDateRange(dateRangeId, startDate,
endDateExcluded);
new SQLUpdateClause(connection, configuration,
qUserSchemeEntityParameter.userSchemeEntityPath)
.set(qUserSchemeEntityParameter.userId, userId)
.where(qUserSchemeEntityParameter.userSchemeId.eq(recordId));
return null;
}));
}
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:21,代码来源:SchemeUsersComponent.java
示例3: updatePublicHoliday
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private void updatePublicHoliday(final long publicHolidayId, final Date date,
final Date replacementDate,
final String description) {
querydslSupport.execute((connection, configuration) -> {
QPublicHoliday qPublicHoliday = QPublicHoliday.publicHoliday;
SQLUpdateClause update = new SQLUpdateClause(connection, configuration, qPublicHoliday)
.set(qPublicHoliday.date, date);
if (replacementDate != null) {
update.set(qPublicHoliday.replacementDate, replacementDate);
} else {
update.setNull(qPublicHoliday.replacementDate);
}
if (description != null) {
update.set(qPublicHoliday.description, description);
} else {
update.setNull(qPublicHoliday.description);
}
update.where(qPublicHoliday.publicHolidayId.eq(publicHolidayId)).execute();
return null;
});
}
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:26,代码来源:HolidaySchemesServlet.java
示例4: updateScheme
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private void updateScheme(final SchemeDTO scheme) {
querydslSupport.execute((connection, configuration) -> {
QWorkScheme qWorkScheme = QWorkScheme.workScheme;
return new SQLUpdateClause(connection, configuration, qWorkScheme)
.set(qWorkScheme.name, scheme.name)
.where(qWorkScheme.workSchemeId.eq(scheme.schemeId))
.execute();
});
}
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:10,代码来源:WorkSchemesServlet.java
示例5: updateScheme
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private void updateScheme(final SchemeDTO scheme) {
querydslSupport.execute((connection, configuration) -> {
QHolidayScheme qHolidayScheme = QHolidayScheme.holidayScheme;
return new SQLUpdateClause(connection, configuration, qHolidayScheme)
.set(qHolidayScheme.name, scheme.name)
.where(qHolidayScheme.holidaySchemeId.eq(scheme.schemeId))
.execute();
});
}
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:10,代码来源:HolidaySchemesServlet.java
示例6: modifyDateRange
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public void modifyDateRange(final long dateRangeId, final Date startDate,
final Date endDateExcluded) {
QDateRange dateRange = QDateRange.dateRange;
new SQLUpdateClause(connection, configuration, dateRange)
.set(dateRange.startDate, startDate)
.set(dateRange.endDateExcluded, endDateExcluded)
.where(dateRange.dateRangeId.eq(dateRangeId)).execute();
vacuumDates();
fillDateSequenceFromRange(startDate, endDateExcluded);
}
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:14,代码来源:DateRangeUtil.java
示例7: updatePorts
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private void updatePorts(long facilityId, Map<Integer, Port> updatedPorts) {
if (updatedPorts != null && !updatedPorts.isEmpty()) {
SQLUpdateClause update = queryFactory.update(qPort);
for (Entry<Integer, Port> entry : updatedPorts.entrySet()) {
Integer portIndex = entry.getKey();
populate(facilityId, portIndex, entry.getValue(), update);
update.where(qPort.facilityId.eq(facilityId), qPort.portIndex.eq(portIndex));
update.addBatch();
}
update.execute();
}
}
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:13,代码来源:FacilityDao.java
示例8: updateContact
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@TransactionalWrite
public void updateContact(long contactId, Contact contact) {
SQLUpdateClause update = queryFactory.update(qContact).where(qContact.id.eq(contactId));
populate(contact, update);
if (update.execute() != 1) {
notFound(contactId);
}
}
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:10,代码来源:ContactDao.java
示例9: updateBatch
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private <T> void updateBatch(Collection<T> batch, RelationalPath<?> expression, BiConsumer<SQLUpdateClause, T> processor) {
if (batch.isEmpty()) {
return;
}
final SQLUpdateClause update = queryFactory.update(expression);
batch.forEach(item -> {
processor.accept(update, item);
update.addBatch();
});
update.execute();
}
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:12,代码来源:RequestLogDao.java
示例10: maybeUpdatePredictionLookupTable
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private long maybeUpdatePredictionLookupTable(UtilizationKey utilizationKey, DateTime start, List<Prediction> predictions) {
SQLUpdateClause update = queryFactory.update(qPrediction)
.where(qPrediction.facilityId.eq(utilizationKey.facilityId),
qPrediction.capacityType.eq(utilizationKey.capacityType),
qPrediction.usage.eq(utilizationKey.usage))
.set(qPrediction.start, start);
predictions.forEach(p -> update.set(spacesAvailableAt(p.timestamp), p.spacesAvailable));
return update.execute();
}
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:11,代码来源:PredictionDao.java
示例11: updateOperator
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@TransactionalWrite
@Override
public void updateOperator(long operatorId, Operator operator) {
SQLUpdateClause update = queryFactory.update(qOperator);
update.where(qOperator.id.eq(operatorId));
nameMapping.populate(operator.name, update);
if (update.execute() != 1) {
notFound(operatorId);
}
}
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:11,代码来源:OperatorDao.java
示例12: updateHub
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@TransactionalWrite
public void updateHub(long hubId, Hub hub) {
SQLUpdateClause update = queryFactory.update(qHub);
update.where(qHub.id.eq(hubId));
populate(hub, update);
if (update.execute() != 1) {
throw new HubNotFoundException(hubId);
}
deleteHubFacilities(hubId);
insertHubFacilities(hubId, hub.facilityIds);
}
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:14,代码来源:HubDao.java
示例13: doPublish
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
protected Multimap<Id, Revision> doPublish() {
Map<Revision, Id> uncommittedRevisions = getUnpublishedRevisionsForUpdate();
long lastOrdinal = getMaxOrdinal();
log.debug("publish({})", uncommittedRevisions.size());
if (uncommittedRevisions.isEmpty()) {
return ImmutableMultimap.of();
}
Multimap<Id, Revision> publishedDocs = ArrayListMultimap.create();
SQLUpdateClause versionUpdateBatch = options.queryFactory.update(options.version);
for (Map.Entry<Revision, Id> entry : uncommittedRevisions.entrySet()) {
Revision revision = entry.getKey();
Id docId = entry.getValue();
publishedDocs.put(docId, revision);
setOrdinal(versionUpdateBatch, ++lastOrdinal)
.where(options.version.revision.eq(revision))
.addBatch();
}
versionUpdateBatch.execute();
afterPublish(publishedDocs);
return publishedDocs;
}
开发者ID:ssaarela,项目名称:javersion,代码行数:28,代码来源:AbstractVersionStoreJdbc.java
示例14: updateHistoricalLocation
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public boolean updateHistoricalLocation(HistoricalLocation hl, UUID id) {
SQLQueryFactory qFactory = pm.createQueryFactory();
QHistLocations qhl = QHistLocations.histLocations;
SQLUpdateClause update = qFactory.update(qhl);
if (hl.isSetThing()) {
if (!entityExists(hl.getThing())) {
throw new IncompleteEntityException("Thing can not be null.");
}
update.set(qhl.thingId, (UUID) hl.getThing().getId().getValue());
}
if (hl.isSetTime()) {
if (hl.getTime() == null) {
throw new IncompleteEntityException("time can not be null.");
}
insertTimeInstant(update, qhl.time, hl.getTime());
}
update.where(qhl.id.eq(id));
long count = 0;
if (!update.isEmpty()) {
count = update.execute();
}
if (count > 1) {
LOGGER.error("Updating Location {} caused {} rows to change!", id, count);
throw new IllegalStateException("Update changed multiple rows.");
}
LOGGER.debug("Updated Location {}", id);
// Link existing locations to the HistoricalLocation.
for (Location l : hl.getLocations()) {
if (!entityExists(l)) {
throw new IllegalArgumentException("Unknown Location or Location with no id.");
}
UUID lId = (UUID) l.getId().getValue();
QLocationsHistLocations qlhl = QLocationsHistLocations.locationsHistLocations;
SQLInsertClause insert = qFactory.insert(qlhl);
insert.set(qlhl.histLocationId, id);
insert.set(qlhl.locationId, lId);
insert.execute();
LOGGER.debug("Linked Location {} to HistoricalLocation {}.", lId, id);
}
return true;
}
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:44,代码来源:EntityInserter.java
示例15: updateObservedProperty
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public boolean updateObservedProperty(ObservedProperty op, UUID opId) throws NoSuchEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QObsProperties qop = QObsProperties.obsProperties;
SQLUpdateClause update = qFactory.update(qop);
if (op.isSetDefinition()) {
if (op.getDefinition() == null) {
throw new IncompleteEntityException("definition can not be null.");
}
update.set(qop.definition, op.getDefinition());
}
if (op.isSetDescription()) {
if (op.getDescription() == null) {
throw new IncompleteEntityException("description can not be null.");
}
update.set(qop.description, op.getDescription());
}
if (op.isSetName()) {
if (op.getName() == null) {
throw new IncompleteEntityException("name can not be null.");
}
update.set(qop.name, op.getName());
}
if (op.isSetProperties()) {
update.set(qop.properties, objectToJson(op.getProperties()));
}
update.where(qop.id.eq(opId));
long count = 0;
if (!update.isEmpty()) {
count = update.execute();
}
if (count > 1) {
LOGGER.error("Updating ObservedProperty {} caused {} rows to change!", opId, count);
throw new IllegalStateException("Update changed multiple rows.");
}
// Link existing Datastreams to the observedProperty.
for (Datastream ds : op.getDatastreams()) {
if (ds.getId() == null || !entityExists(ds)) {
throw new NoSuchEntityException("ObservedProperty with no id or non existing.");
}
UUID dsId = (UUID) ds.getId().getValue();
QDatastreams qds = QDatastreams.datastreams;
long dsCount = qFactory.update(qds)
.set(qds.obsPropertyId, opId)
.where(qds.id.eq(dsId))
.execute();
if (dsCount > 0) {
LOGGER.info("Assigned datastream {} to ObservedProperty {}.", dsId, opId);
}
}
if (!op.getMultiDatastreams().isEmpty()) {
throw new IllegalArgumentException("Can not add MultiDatastreams to an ObservedProperty.");
}
LOGGER.debug("Updated ObservedProperty {}", opId);
return true;
}
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:60,代码来源:EntityInserter.java
示例16: updateSensor
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public boolean updateSensor(Sensor s, UUID sensorId) throws NoSuchEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QSensors qs = QSensors.sensors;
SQLUpdateClause update = qFactory.update(qs);
if (s.isSetName()) {
if (s.getName() == null) {
throw new IncompleteEntityException("name can not be null.");
}
update.set(qs.name, s.getName());
}
if (s.isSetDescription()) {
if (s.getDescription() == null) {
throw new IncompleteEntityException("description can not be null.");
}
update.set(qs.description, s.getDescription());
}
if (s.isSetEncodingType()) {
if (s.getEncodingType() == null) {
throw new IncompleteEntityException("encodingType can not be null.");
}
update.set(qs.encodingType, s.getEncodingType());
}
if (s.isSetMetadata()) {
if (s.getMetadata() == null) {
throw new IncompleteEntityException("metadata can not be null.");
}
// TODO: Check metadata serialisation.
update.set(qs.metadata, s.getMetadata().toString());
}
if (s.isSetProperties()) {
update.set(qs.properties, objectToJson(s.getProperties()));
}
update.where(qs.id.eq(sensorId));
long count = 0;
if (!update.isEmpty()) {
count = update.execute();
}
if (count > 1) {
LOGGER.error("Updating Sensor {} caused {} rows to change!", sensorId, count);
throw new IllegalStateException("Update changed multiple rows.");
}
// Link existing Datastreams to the sensor.
for (Datastream ds : s.getDatastreams()) {
if (ds.getId() == null || !entityExists(ds)) {
throw new NoSuchEntityException("Datastream with no id or non existing.");
}
UUID dsId = (UUID) ds.getId().getValue();
QDatastreams qds = QDatastreams.datastreams;
long dsCount = qFactory.update(qds)
.set(qds.sensorId, sensorId)
.where(qds.id.eq(dsId))
.execute();
if (dsCount > 0) {
LOGGER.info("Assigned datastream {} to sensor {}.", dsId, sensorId);
}
}
// Link existing MultiDatastreams to the sensor.
for (MultiDatastream mds : s.getMultiDatastreams()) {
if (mds.getId() == null || !entityExists(mds)) {
throw new NoSuchEntityException("MultiDatastream with no id or non existing.");
}
UUID mdsId = (UUID) mds.getId().getValue();
QMultiDatastreams qmds = QMultiDatastreams.multiDatastreams;
long mdsCount = qFactory.update(qmds)
.set(qmds.sensorId, sensorId)
.where(qmds.id.eq(mdsId))
.execute();
if (mdsCount > 0) {
LOGGER.info("Assigned multiDatastream {} to sensor {}.", mdsId, sensorId);
}
}
LOGGER.debug("Updated Sensor {}", sensorId);
return true;
}
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:79,代码来源:EntityInserter.java
示例17: updateHistoricalLocation
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public boolean updateHistoricalLocation(HistoricalLocation hl, long id) {
SQLQueryFactory qFactory = pm.createQueryFactory();
QHistLocations qhl = QHistLocations.histLocations;
SQLUpdateClause update = qFactory.update(qhl);
if (hl.isSetThing()) {
if (!entityExists(hl.getThing())) {
throw new IncompleteEntityException("Thing can not be null.");
}
update.set(qhl.thingId, (Long) hl.getThing().getId().getValue());
}
if (hl.isSetTime()) {
if (hl.getTime() == null) {
throw new IncompleteEntityException("time can not be null.");
}
insertTimeInstant(update, qhl.time, hl.getTime());
}
update.where(qhl.id.eq(id));
long count = 0;
if (!update.isEmpty()) {
count = update.execute();
}
if (count > 1) {
LOGGER.error("Updating Location {} caused {} rows to change!", id, count);
throw new IllegalStateException("Update changed multiple rows.");
}
LOGGER.debug("Updated Location {}", id);
// Link existing locations to the HistoricalLocation.
for (Location l : hl.getLocations()) {
if (!entityExists(l)) {
throw new IllegalArgumentException("Unknown Location or Location with no id.");
}
Long lId = (Long) l.getId().getValue();
QLocationsHistLocations qlhl = QLocationsHistLocations.locationsHistLocations;
SQLInsertClause insert = qFactory.insert(qlhl);
insert.set(qlhl.histLocationId, id);
insert.set(qlhl.locationId, lId);
insert.execute();
LOGGER.debug("Linked Location {} to HistoricalLocation {}.", lId, id);
}
return true;
}
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:44,代码来源:EntityInserter.java
示例18: updateObservedProperty
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public boolean updateObservedProperty(ObservedProperty op, long opId) throws NoSuchEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QObsProperties qop = QObsProperties.obsProperties;
SQLUpdateClause update = qFactory.update(qop);
if (op.isSetDefinition()) {
if (op.getDefinition() == null) {
throw new IncompleteEntityException("definition can not be null.");
}
update.set(qop.definition, op.getDefinition());
}
if (op.isSetDescription()) {
if (op.getDescription() == null) {
throw new IncompleteEntityException("description can not be null.");
}
update.set(qop.description, op.getDescription());
}
if (op.isSetName()) {
if (op.getName() == null) {
throw new IncompleteEntityException("name can not be null.");
}
update.set(qop.name, op.getName());
}
if (op.isSetProperties()) {
update.set(qop.properties, objectToJson(op.getProperties()));
}
update.where(qop.id.eq(opId));
long count = 0;
if (!update.isEmpty()) {
count = update.execute();
}
if (count > 1) {
LOGGER.error("Updating ObservedProperty {} caused {} rows to change!", opId, count);
throw new IllegalStateException("Update changed multiple rows.");
}
// Link existing Datastreams to the observedProperty.
for (Datastream ds : op.getDatastreams()) {
if (ds.getId() == null || !entityExists(ds)) {
throw new NoSuchEntityException("ObservedProperty with no id or non existing.");
}
Long dsId = (Long) ds.getId().getValue();
QDatastreams qds = QDatastreams.datastreams;
long dsCount = qFactory.update(qds)
.set(qds.obsPropertyId, opId)
.where(qds.id.eq(dsId))
.execute();
if (dsCount > 0) {
LOGGER.info("Assigned datastream {} to ObservedProperty {}.", dsId, opId);
}
}
if (!op.getMultiDatastreams().isEmpty()) {
throw new IllegalArgumentException("Can not add MultiDatastreams to an ObservedProperty.");
}
LOGGER.debug("Updated ObservedProperty {}", opId);
return true;
}
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:60,代码来源:EntityInserter.java
示例19: updateSensor
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public boolean updateSensor(Sensor s, long sensorId) throws NoSuchEntityException {
SQLQueryFactory qFactory = pm.createQueryFactory();
QSensors qs = QSensors.sensors;
SQLUpdateClause update = qFactory.update(qs);
if (s.isSetName()) {
if (s.getName() == null) {
throw new IncompleteEntityException("name can not be null.");
}
update.set(qs.name, s.getName());
}
if (s.isSetDescription()) {
if (s.getDescription() == null) {
throw new IncompleteEntityException("description can not be null.");
}
update.set(qs.description, s.getDescription());
}
if (s.isSetEncodingType()) {
if (s.getEncodingType() == null) {
throw new IncompleteEntityException("encodingType can not be null.");
}
update.set(qs.encodingType, s.getEncodingType());
}
if (s.isSetMetadata()) {
if (s.getMetadata() == null) {
throw new IncompleteEntityException("metadata can not be null.");
}
// TODO: Check metadata serialisation.
update.set(qs.metadata, s.getMetadata().toString());
}
if (s.isSetProperties()) {
update.set(qs.properties, objectToJson(s.getProperties()));
}
update.where(qs.id.eq(sensorId));
long count = 0;
if (!update.isEmpty()) {
count = update.execute();
}
if (count > 1) {
LOGGER.error("Updating Sensor {} caused {} rows to change!", sensorId, count);
throw new IllegalStateException("Update changed multiple rows.");
}
// Link existing Datastreams to the sensor.
for (Datastream ds : s.getDatastreams()) {
if (ds.getId() == null || !entityExists(ds)) {
throw new NoSuchEntityException("Datastream with no id or non existing.");
}
Long dsId = (Long) ds.getId().getValue();
QDatastreams qds = QDatastreams.datastreams;
long dsCount = qFactory.update(qds)
.set(qds.sensorId, sensorId)
.where(qds.id.eq(dsId))
.execute();
if (dsCount > 0) {
LOGGER.info("Assigned datastream {} to sensor {}.", dsId, sensorId);
}
}
// Link existing MultiDatastreams to the sensor.
for (MultiDatastream mds : s.getMultiDatastreams()) {
if (mds.getId() == null || !entityExists(mds)) {
throw new NoSuchEntityException("MultiDatastream with no id or non existing.");
}
Long mdsId = (Long) mds.getId().getValue();
QMultiDatastreams qmds = QMultiDatastreams.multiDatastreams;
long mdsCount = qFactory.update(qmds)
.set(qmds.sensorId, sensorId)
.where(qmds.id.eq(mdsId))
.execute();
if (mdsCount > 0) {
LOGGER.info("Assigned multiDatastream {} to sensor {}.", mdsId, sensorId);
}
}
LOGGER.debug("Updated Sensor {}", sensorId);
return true;
}
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:79,代码来源:EntityInserter.java
示例20: updateHistoricalLocation
import com.querydsl.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public boolean updateHistoricalLocation(HistoricalLocation hl, String id) {
SQLQueryFactory qFactory = pm.createQueryFactory();
QHistLocations qhl = QHistLocations.histLocations;
SQLUpdateClause update = qFactory.update(qhl);
if (hl.isSetThing()) {
if (!entityExists(hl.getThing())) {
throw new IncompleteEntityException("Thing can not be null.");
}
update.set(qhl.thingId, (String) hl.getThing().getId().getValue());
}
if (hl.isSetTime()) {
if (hl.getTime() == null) {
throw new IncompleteEntityException("time can not be null.");
}
insertTimeInstant(update, qhl.time, hl.getTime());
}
update.where(qhl.id.eq(id));
long count = 0;
if (!update.isEmpty()) {
count = update.execute();
}
if (count > 1) {
LOGGER.error("Updating Location {} caused {} rows to change!", id, count);
throw new IllegalStateException("Update changed multiple rows.");
}
LOGGER.debug("Updated Location {}", id);
// Link existing locations to the HistoricalLocation.
for (Location l : hl.getLocations()) {
if (!entityExists(l)) {
throw new IllegalArgumentException("Unknown Location or Location with no id.");
}
String lId = (String) l.getId().getValue();
QLocationsHistLocations qlhl = QLocationsHistLocations.locationsHistLocations;
SQLInsertClause insert = qFactory.insert(qlhl);
insert.set(qlhl.histLocationId, id);
insert.set(qlhl.locationId, lId);
insert.execute();
LOGGER.debug("Linked Location {} to HistoricalLocation {}.", lId, id);
}
return true;
}
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:44,代码来源:EntityInserter.java
注:本文中的com.querydsl.sql.dml.SQLUpdateClause类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论