本文整理汇总了Java中org.springframework.orm.jpa.JpaSystemException.getRootCause方法的典型用法代码示例。如果您正苦于以下问题:Java JpaSystemException.getRootCause方法的具体用法?Java JpaSystemException.getRootCause怎么用?Java JpaSystemException.getRootCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.orm.jpa.JpaSystemException
的用法示例。
在下文中一共展示了JpaSystemException.getRootCause方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: persistAndRetryIfMacCollision
import org.springframework.orm.jpa.JpaSystemException; //导入方法依赖的package包/类
private VmNicVO persistAndRetryIfMacCollision(VmNicVO vo) {
int tries = 5;
while (tries-- > 0) {
try {
vo = dbf.persistAndRefresh(vo);
return vo;
} catch (JpaSystemException e) {
if (e.getRootCause() instanceof MySQLIntegrityConstraintViolationException &&
e.getRootCause().getMessage().contains("Duplicate entry")) {
logger.debug(String.format("Concurrent mac allocation. Mac[%s] has been allocated, try allocating another one. " +
"The error[Duplicate entry] printed by jdbc.spi.SqlExceptionHelper is no harm, " +
"we will try finding another mac", vo.getMac()));
logger.trace("", e);
vo.setMac(NetworkUtils.generateMacWithDeviceId((short) vo.getDeviceId()));
} else {
throw e;
}
}
}
return null;
}
示例2: handle
import org.springframework.orm.jpa.JpaSystemException; //导入方法依赖的package包/类
private void handle(APICreateLdapBindingMsg msg) {
APICreateLdapBindingEvent evt = new APICreateLdapBindingEvent(msg.getId());
// account check
SimpleQuery<AccountVO> sq = dbf.createQuery(AccountVO.class);
sq.add(AccountVO_.uuid, SimpleQuery.Op.EQ, msg.getAccountUuid());
AccountVO avo = sq.find();
if (avo == null) {
evt.setError(errf.instantiateErrorCode(LdapErrors.CANNOT_FIND_ACCOUNT,
String.format("cannot find the specified account[uuid:%s]", msg.getAccountUuid())));
bus.publish(evt);
return;
}
String ldapUseAsLoginName = LdapUtil.getLdapUseAsLoginName();
// bind op
LdapTemplateContextSource ldapTemplateContextSource = readLdapServerConfiguration();
String fullDn = msg.getLdapUid();
if (!validateDnExist(ldapTemplateContextSource, fullDn)) {
throw new OperationFailureException(errf.instantiateErrorCode(LdapErrors.UNABLE_TO_GET_SPECIFIED_LDAP_UID,
String.format("cannot find dn[%s] on ldap server[Address:%s, BaseDN:%s].", fullDn,
String.join(", ", ldapTemplateContextSource.getLdapContextSource().getUrls()),
ldapTemplateContextSource.getLdapContextSource().getBaseLdapPathAsString())));
}
try {
evt.setInventory(bindLdapAccount(msg.getAccountUuid(), fullDn));
logger.info(String.format("create ldap binding[ldapUid=%s, ldapUseAsLoginName=%s] success", fullDn, ldapUseAsLoginName));
} catch (JpaSystemException e) {
if (e.getRootCause() instanceof MySQLIntegrityConstraintViolationException) {
evt.setError(errf.instantiateErrorCode(LdapErrors.BIND_SAME_LDAP_UID_TO_MULTI_ACCOUNT,
"The ldap uid has been bound to an account. "));
} else {
throw e;
}
}
bus.publish(evt);
}
示例3: reserveIp
import org.springframework.orm.jpa.JpaSystemException; //导入方法依赖的package包/类
@Override
public UsedIpInventory reserveIp(IpRangeInventory ipRange, String ip) {
try {
UsedIpVO vo = new UsedIpVO(ipRange.getUuid(), ip);
vo.setIpInLong(NetworkUtils.ipv4StringToLong(ip));
String uuid = ipRange.getUuid() + ip;
uuid = UUID.nameUUIDFromBytes(uuid.getBytes()).toString().replaceAll("-", "");
vo.setUuid(uuid);
vo.setL3NetworkUuid(ipRange.getL3NetworkUuid());
vo.setNetmask(ipRange.getNetmask());
vo.setGateway(ipRange.getGateway());
vo = dbf.persistAndRefresh(vo);
return UsedIpInventory.valueOf(vo);
} catch (JpaSystemException e) {
if (e.getRootCause() instanceof MySQLIntegrityConstraintViolationException) {
logger.debug(String.format("Concurrent ip allocation. " +
"Ip[%s] in ip range[uuid:%s] has been allocated, try allocating another one. " +
"The error[Duplicate entry] printed by jdbc.spi.SqlExceptionHelper is no harm, " +
"we will try finding another ip", ip, ipRange.getUuid()));
logger.trace("", e);
} else {
throw e;
}
}
return null;
}