io.ebean.config.dbplatform.SqlErrorCodes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebean.config.dbplatform;
import java.util.HashMap;
import java.util.Map;
/**
* Used to build a SQLCodeTranslator given DB platform specific codes.
*/
public class SqlErrorCodes {
private Map map = new HashMap<>();
/**
* Map the codes to AcquireLockException.
*/
public SqlErrorCodes addAcquireLock(String... codes) {
return add(DataErrorType.AcquireLock, codes);
}
/**
* Map the codes to DataIntegrityException.
*/
public SqlErrorCodes addDataIntegrity(String... codes) {
return add(DataErrorType.DataIntegrity, codes);
}
/**
* Map the codes to DuplicateKeyException.
*/
public SqlErrorCodes addDuplicateKey(String... codes) {
return add(DataErrorType.DuplicateKey, codes);
}
private SqlErrorCodes add(DataErrorType type, String... codes) {
for (String code : codes) {
map.put(code, type);
}
return this;
}
/**
* Build and return the SQLCodeTranslator with the mapped codes.
*/
public SqlCodeTranslator build() {
return new SqlCodeTranslator(map);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy