本文整理了Java中org.hibernate.classic.Session.saveOrUpdate()
方法的一些代码示例,展示了Session.saveOrUpdate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.saveOrUpdate()
方法的具体详情如下:
包路径:org.hibernate.classic.Session
类名称:Session
方法名:saveOrUpdate
[英]Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved or does not exist in the database, save it and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.
[中]
代码示例来源:origin: gocd/gocd
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
sessionFactory.getCurrentSession().saveOrUpdate(versionInfo);
}
});
代码示例来源:origin: gocd/gocd
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
transactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
clearEnabledUserCountFromCache();
}
});
sessionFactory.getCurrentSession().saveOrUpdate(copyLoginToDisplayNameIfNotPresent(user));
}
});
代码示例来源:origin: gocd/gocd
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
sessionFactory.getCurrentSession().saveOrUpdate(plugin);
goCache.remove(cacheKey);
}
});
代码示例来源:origin: gocd/gocd
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
synchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
String cacheKey = cacheKeyForUsageStatisticsReporting();
synchronized (cacheKey) {
goCache.remove(cacheKey);
}
}
});
sessionFactory.getCurrentSession().saveOrUpdate(usageStatisticsReporting);
}
});
代码示例来源:origin: gocd/gocd
public void saveOrUpdate(DataSharingSettings dataSharingSettings) throws DuplicateDataSharingSettingsException {
DataSharingSettings existing = load();
if (dataSharingSettings.hasId() && dataSharingSettings.getId() != existing.getId()) {
throw new DuplicateDataSharingSettingsException();
}
if (existing != null) {
existing.copyFrom(dataSharingSettings);
} else {
existing = dataSharingSettings;
}
sessionFactory.getCurrentSession().saveOrUpdate(existing);
}
代码示例来源:origin: gocd/gocd
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
transactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
clearLockedPipelineStateCache(pipelineName);
}
});
transactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCompletion(int status) {
for (AfterCompletionCallback callback : afterCompletionCallbacks) {
callback.execute(status);
}
}
});
final String cacheKey = pipelineLockStateCacheKey(pipelineName);
PipelineState fromCache = pipelineStateFor(pipelineName);
PipelineState toBeSaved = null;
if (fromCache == null) {
toBeSaved = new PipelineState(pipelineName);
} else {
toBeSaved = (PipelineState) sessionFactory.getCurrentSession().load(PipelineState.class, fromCache.getId());
}
toBeSaved.unlock();
sessionFactory.getCurrentSession().saveOrUpdate(toBeSaved);
}
});
代码示例来源:origin: gocd/gocd
sessionFactory.getCurrentSession().saveOrUpdate(toBeSaved);
代码示例来源:origin: denimgroup/threadfix
@Override
public void saveOrUpdate(EmptyScan emptyScan) {
sessionFactory.getCurrentSession().saveOrUpdate(emptyScan);
}
}
代码示例来源:origin: org.motechproject/motech-server-core
public Stratum updateStratum(Stratum stratum) {
Session session = sessionFactory.getCurrentSession();
session.saveOrUpdate(stratum);
return stratum;
}
代码示例来源:origin: denimgroup/threadfix
@Override
public void saveOrUpdate(VulnerabilityFilter vulnerabilityFilter) {
if (vulnerabilityFilter != null && vulnerabilityFilter.getId() != null) {
sessionFactory.getCurrentSession().merge(vulnerabilityFilter);
} else {
sessionFactory.getCurrentSession().saveOrUpdate(vulnerabilityFilter);
}
}
代码示例来源:origin: denimgroup/threadfix
@Override
public void saveOrUpdate(AccessControlApplicationMap map) {
if (map != null && map.getId() != null) {
sessionFactory.getCurrentSession().merge(map);
} else {
sessionFactory.getCurrentSession().saveOrUpdate(map);
}
}
代码示例来源:origin: denimgroup/threadfix
@Override
public void saveOrUpdate(AccessControlTeamMap map) {
if (map != null && map.getId() != null) {
sessionFactory.getCurrentSession().merge(map);
} else {
sessionFactory.getCurrentSession().saveOrUpdate(map);
}
}
代码示例来源:origin: denimgroup/threadfix
@Override
public void saveOrUpdate(Application application) {
if (application != null && application.getId() != null) {
sessionFactory.getCurrentSession().merge(application);
} else {
sessionFactory.getCurrentSession().saveOrUpdate(application);
}
}
代码示例来源:origin: denimgroup/threadfix
@Override
public void saveOrUpdate(ChannelSeverity channelSeverity) {
if (channelSeverity.getSeverityMap() != null) {
sessionFactory.getCurrentSession().saveOrUpdate(channelSeverity.getSeverityMap());
}
sessionFactory.getCurrentSession().saveOrUpdate(channelSeverity);
sessionFactory.getCurrentSession().flush();
sessionFactory.getCurrentSession().refresh(channelSeverity);
}
代码示例来源:origin: denimgroup/threadfix
@Override
public void saveOrUpdate(Role role) {
if (role != null && role.getId() != null) {
sessionFactory.getCurrentSession().merge(role);
} else {
sessionFactory.getCurrentSession().saveOrUpdate(role);
}
}
代码示例来源:origin: org.geomajas/geomajas-project-deskmanager
@Override
public AuthenticationSession createSession(User user, int lifetimeInDays) {
if (lifetimeInDays < 1) {
throw new IllegalArgumentException("Lifetime attribute must be a positive integer");
}
AuthenticationSession session = new AuthenticationSession(generateToken(),
user, getCurrentDatePlusDays(lifetimeInDays));
sessionFactory.getCurrentSession().saveOrUpdate(session);
return session;
}
代码示例来源:origin: org.geomajas/geomajas-project-deskmanager
public void saveOrUpdateLayerModel(LayerModel lm) throws GeomajasSecurityException {
if (((DeskmanagerSecurityContext) securityContext).saveAllowed(lm)) {
factory.getCurrentSession().saveOrUpdate(lm);
} else {
throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Save layermodel",
securityContext.getUserName());
}
}
代码示例来源:origin: org.geomajas/geomajas-project-deskmanager
public void deleteBlueprint(Blueprint bp) throws GeomajasSecurityException {
if (((DeskmanagerSecurityContext) securityContext).deleteAllowed(bp)) {
bp.setDeleted(true);
factory.getCurrentSession().saveOrUpdate(bp);
} else {
throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Delete blueprint",
securityContext.getUserName());
}
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-deskmanager
public void deleteBlueprint(Blueprint bp) throws GeomajasSecurityException {
if (((DeskmanagerSecurityContext) securityContext).deleteAllowed(bp)) {
bp.setDeleted(true);
factory.getCurrentSession().saveOrUpdate(bp);
} else {
throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Delete blueprint",
securityContext.getUserName());
}
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-deskmanager
@Override
public void updateUser(User user) throws GeomajasSecurityException {
// need to get the user from db before updating: password is also in this object.
User userDb = findById(user.getId());
/*userDb.setEmail(user.getEmail());*/ //can't update email
userDb.setName(user.getName());
userDb.setSurname(user.getSurname());
userDb.setActive(user.isActive());
factory.getCurrentSession().saveOrUpdate(userDb);
}
内容来源于网络,如有侵权,请联系作者删除!