Revision 50657
Added by Claudio Atzori about 6 years ago
SQLiteDialect.java | ||
---|---|---|
1 |
/* |
|
2 |
* The author disclaims copyright to this source code. In place of a legal notice, here is a blessing: |
|
3 |
* |
|
4 |
* May you do good and not evil. May you find forgiveness for yourself and forgive others. May you share freely, never taking more than you |
|
5 |
* give. |
|
6 |
*/ |
|
7 | 1 |
package org.hibernate.dialect; |
8 | 2 |
|
9 | 3 |
import java.sql.SQLException; |
10 | 4 |
import java.sql.Types; |
11 | 5 |
|
12 |
import org.hibernate.JDBCException; |
|
13 |
import org.hibernate.dialect.function.AbstractAnsiTrimEmulationFunction; |
|
14 |
import org.hibernate.dialect.function.NoArgSQLFunction; |
|
15 |
import org.hibernate.dialect.function.SQLFunction; |
|
16 |
import org.hibernate.dialect.function.SQLFunctionTemplate; |
|
17 |
import org.hibernate.dialect.function.StandardSQLFunction; |
|
18 |
import org.hibernate.dialect.function.VarArgsSQLFunction; |
|
19 |
import org.hibernate.exception.ConstraintViolationException; |
|
20 |
import org.hibernate.exception.DataException; |
|
21 |
import org.hibernate.exception.GenericJDBCException; |
|
22 |
import org.hibernate.exception.JDBCConnectionException; |
|
23 |
import org.hibernate.exception.LockAcquisitionException; |
|
6 |
import org.hibernate.dialect.function.*; |
|
7 |
import org.hibernate.exception.*; |
|
24 | 8 |
import org.hibernate.exception.spi.SQLExceptionConverter; |
25 | 9 |
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter; |
26 | 10 |
import org.hibernate.exception.spi.ViolatedConstraintNameExtracter; |
... | ... | |
193 | 177 |
|
194 | 178 |
@Override |
195 | 179 |
public SQLExceptionConverter buildSQLExceptionConverter() { |
196 |
return new SQLExceptionConverter() { |
|
197 |
|
|
198 |
@Override |
|
199 |
public JDBCException convert(final SQLException sqlException, final String message, final String sql) { |
|
200 |
final int errorCode = JdbcExceptionHelper.extractErrorCode(sqlException); |
|
201 |
if (errorCode == SQLITE_CONSTRAINT) { |
|
202 |
final String constraintName = EXTRACTER.extractConstraintName(sqlException); |
|
203 |
return new ConstraintViolationException(message, sqlException, sql, constraintName); |
|
204 |
} else if ((errorCode == SQLITE_TOOBIG) || (errorCode == SQLITE_MISMATCH)) return new DataException(message, sqlException, sql); |
|
205 |
else if ((errorCode == SQLITE_BUSY) || (errorCode == SQLITE_LOCKED)) return new LockAcquisitionException(message, sqlException, sql); |
|
206 |
else if (((errorCode >= SQLITE_IOERR) && (errorCode <= SQLITE_PROTOCOL)) || (errorCode == SQLITE_NOTADB)) |
|
207 |
return new JDBCConnectionException(message, sqlException, sql); |
|
208 |
return new GenericJDBCException(message, sqlException, sql); |
|
209 |
} |
|
180 |
return (SQLExceptionConverter) (sqlException, message, sql) -> { |
|
181 |
final int errorCode = JdbcExceptionHelper.extractErrorCode(sqlException); |
|
182 |
if (errorCode == SQLITE_CONSTRAINT) { |
|
183 |
final String constraintName = EXTRACTER.extractConstraintName(sqlException); |
|
184 |
return new ConstraintViolationException(message, sqlException, sql, constraintName); |
|
185 |
} else if ((errorCode == SQLITE_TOOBIG) || (errorCode == SQLITE_MISMATCH)) return new DataException(message, sqlException, sql); |
|
186 |
else if ((errorCode == SQLITE_BUSY) || (errorCode == SQLITE_LOCKED)) return new LockAcquisitionException(message, sqlException, sql); |
|
187 |
else if (((errorCode >= SQLITE_IOERR) && (errorCode <= SQLITE_PROTOCOL)) || (errorCode == SQLITE_NOTADB)) |
|
188 |
return new JDBCConnectionException(message, sqlException, sql); |
|
189 |
return new GenericJDBCException(message, sqlException, sql); |
|
210 | 190 |
}; |
211 | 191 |
} |
212 | 192 |
|
... | ... | |
272 | 252 |
return true; |
273 | 253 |
} |
274 | 254 |
|
275 |
/* |
|
276 |
* public boolean supportsCascadeDelete() { return true; } |
|
277 |
*/ |
|
278 |
|
|
279 |
/* |
|
280 |
* not case insensitive for unicode characters by default (ICU extension needed) public boolean supportsCaseInsensitiveLike() { return |
|
281 |
* true; } |
|
282 |
*/ |
|
283 |
|
|
284 | 255 |
@Override |
285 | 256 |
public boolean supportsTupleDistinctCounts() { |
286 | 257 |
return false; |
Also available in: Unified diff
using commons-lang3