org.springframework.dao.DataRetrievalFailureException Java Examples
The following examples show how to use
org.springframework.dao.DataRetrievalFailureException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeneratedKeyHolder.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public Number getKey() throws InvalidDataAccessApiUsageException, DataRetrievalFailureException { if (this.keyList.size() == 0) { return null; } if (this.keyList.size() > 1 || this.keyList.get(0).size() > 1) { throw new InvalidDataAccessApiUsageException( "The getKey method should only be used when a single key is returned. " + "The current key entry contains multiple keys: " + this.keyList); } Iterator<Object> keyIter = this.keyList.get(0).values().iterator(); if (keyIter.hasNext()) { Object key = keyIter.next(); if (!(key instanceof Number)) { throw new DataRetrievalFailureException( "The generated key is not of a supported numeric type. " + "Unable to cast [" + (key != null ? key.getClass().getName() : null) + "] to [" + Number.class.getName() + "]"); } return (Number) key; } else { throw new DataRetrievalFailureException("Unable to retrieve the generated key. " + "Check that the table has an identity column enabled."); } }
Example #2
Source File: JdbcOwnerRepositoryImpl.java From spring-graalvm-native with Apache License 2.0 | 6 votes |
/** * Loads the {@link Owner} with the supplied <code>id</code>; also loads the * {@link Pet Pets} and {@link Visit Visits} for the corresponding owner, if not * already loaded. */ @Override public Owner findById(int id) throws DataAccessException { Owner owner; try { Map<String, Object> params = new HashMap<>(); params.put("id", id); owner = this.namedParameterJdbcTemplate.queryForObject( "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id", params, BeanPropertyRowMapper.newInstance(Owner.class)); } catch (EmptyResultDataAccessException ex) { throw new DataRetrievalFailureException("Cannot find Owner: " + id); } loadPetsAndVisits(owner); return owner; }
Example #3
Source File: StageSqlMapDao.java From gocd with Apache License 2.0 | 6 votes |
@Override public Stage stageById(long id) { String key = cacheKeyForStageById(id); Stage stage = (Stage) goCache.get(key); if (stage == null) { synchronized (key) { stage = (Stage) goCache.get(key); if (stage == null) { stage = (Stage) getSqlMapClientTemplate().queryForObject("getStageById", id); if (stage == null) { throw new DataRetrievalFailureException("Unable to load related stage data for id " + id); } goCache.put(key, stage); } } } return cloner.deepClone(stage); }
Example #4
Source File: KeyValuePersistenceExceptionTranslator.java From spring-data-keyvalue with Apache License 2.0 | 6 votes |
@Nullable @Override public DataAccessException translateExceptionIfPossible(RuntimeException exception) { Assert.notNull(exception, "Exception must not be null!"); if (exception instanceof DataAccessException) { return (DataAccessException) exception; } if (exception instanceof NoSuchElementException || exception instanceof IndexOutOfBoundsException || exception instanceof IllegalStateException) { return new DataRetrievalFailureException(exception.getMessage(), exception); } if (exception.getClass().getName().startsWith("java")) { return new UncategorizedKeyValueException(exception.getMessage(), exception); } return null; }
Example #5
Source File: GeneratedKeyHolder.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public Number getKey() throws InvalidDataAccessApiUsageException, DataRetrievalFailureException { if (this.keyList.size() == 0) { return null; } if (this.keyList.size() > 1 || this.keyList.get(0).size() > 1) { throw new InvalidDataAccessApiUsageException( "The getKey method should only be used when a single key is returned. " + "The current key entry contains multiple keys: " + this.keyList); } Iterator<Object> keyIter = this.keyList.get(0).values().iterator(); if (keyIter.hasNext()) { Object key = keyIter.next(); if (!(key instanceof Number)) { throw new DataRetrievalFailureException( "The generated key is not of a supported numeric type. " + "Unable to cast [" + (key != null ? key.getClass().getName() : null) + "] to [" + Number.class.getName() + "]"); } return (Number) key; } else { throw new DataRetrievalFailureException("Unable to retrieve the generated key. " + "Check that the table has an identity column enabled."); } }
Example #6
Source File: JdbcKeyHolder.java From nestedj with MIT License | 6 votes |
@SuppressWarnings("unchecked") public <T> T getKeyValueAs(Class<T> keyClass) { if (this.getKeyList().isEmpty()) { return null; } else if (this.getKeyList().size() <= 1 && this.getKeyList().get(0).size() <= 1) { Iterator<Object> keyIter = ((Map)this.getKeyList().get(0)).values().iterator(); if (keyIter.hasNext()) { Object key = keyIter.next(); if (!(keyClass.isAssignableFrom(key.getClass()))) { throw new DataRetrievalFailureException("The generated key is not of a supported type. Unable to cast [" + key.getClass().getName() + "] to [" + keyClass.getName() + "]"); } else { return keyClass.cast(key); } } else { throw new DataRetrievalFailureException("Unable to retrieve the generated key. Check that the table has an identity column enabled."); } } else { throw new InvalidDataAccessApiUsageException("The getKey method should only be used when a single key is returned. The current key entry contains multiple keys: " + this.getKeyList()); } }
Example #7
Source File: GeneratedKeyHolder.java From effectivejava with Apache License 2.0 | 6 votes |
@Override public Number getKey() throws InvalidDataAccessApiUsageException, DataRetrievalFailureException { if (this.keyList.size() == 0) { return null; } if (this.keyList.size() > 1 || this.keyList.get(0).size() > 1) { throw new InvalidDataAccessApiUsageException( "The getKey method should only be used when a single key is returned. " + "The current key entry contains multiple keys: " + this.keyList); } Iterator<Object> keyIter = this.keyList.get(0).values().iterator(); if (keyIter.hasNext()) { Object key = keyIter.next(); if (!(key instanceof Number)) { throw new DataRetrievalFailureException( "The generated key is not of a supported numeric type. " + "Unable to cast [" + (key != null ? key.getClass().getName() : null) + "] to [" + Number.class.getName() + "]"); } return (Number) key; } else { throw new DataRetrievalFailureException("Unable to retrieve the generated key. " + "Check that the table has an identity column enabled."); } }
Example #8
Source File: KeyHolderTests.java From effectivejava with Apache License 2.0 | 5 votes |
public void testNoKeyReturnedInMap(){ List<Map<String, Object>> l = new LinkedList<Map<String, Object>>(); Map<String, Object> m = new HashMap<String, Object>(); l.add(m); kh.getKeyList().addAll(l); try { kh.getKey(); } catch (DataRetrievalFailureException e) { assertTrue(e.getMessage().startsWith("Unable to retrieve the generated key.")); } }
Example #9
Source File: KeyHolderTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void noKeyReturnedInMap() { kh.getKeyList().addAll(singletonList(emptyMap())); exception.expect(DataRetrievalFailureException.class); exception.expectMessage(startsWith("Unable to retrieve the generated key.")); kh.getKey(); }
Example #10
Source File: MappingCommAreaOperation.java From spring-analysis-note with MIT License | 5 votes |
@Override protected final Record createInputRecord(RecordFactory recordFactory, Object inObject) { try { return new CommAreaRecord(objectToBytes(inObject)); } catch (IOException ex) { throw new DataRetrievalFailureException("I/O exception during bytes conversion", ex); } }
Example #11
Source File: HistoryLevelDeterminatorJdbcTemplateImplTest.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 5 votes |
@Test public void determinedExceptionIgnoringTest() throws Exception { HistoryLevelDeterminatorJdbcTemplateImpl determinator = new HistoryLevelDeterminatorJdbcTemplateImpl(); final String defaultHistoryLevel = "test"; determinator.setDefaultHistoryLevel(defaultHistoryLevel); determinator.setJdbcTemplate(jdbcTemplate); determinator.setCamundaBpmProperties(camundaBpmProperties); determinator.afterPropertiesSet(); when(jdbcTemplate.queryForObject(determinator.getSql(), Integer.class)).thenThrow(new DataRetrievalFailureException("")); String determineHistoryLevel = determinator.determineHistoryLevel(); assertEquals(determinator.defaultHistoryLevel, determineHistoryLevel); verify(jdbcTemplate).queryForObject(determinator.getSql(), Integer.class); }
Example #12
Source File: HistoryLevelDeterminatorJdbcTemplateImplTest.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 5 votes |
@Test(expected = DataRetrievalFailureException.class) public void determinedExceptionNotIgnoringTest() throws Exception { HistoryLevelDeterminatorJdbcTemplateImpl determinator = new HistoryLevelDeterminatorJdbcTemplateImpl(); determinator.setIgnoreDataAccessException(false); final String defaultHistoryLevel = "test"; determinator.setDefaultHistoryLevel(defaultHistoryLevel); determinator.setJdbcTemplate(jdbcTemplate); determinator.setCamundaBpmProperties(camundaBpmProperties); determinator.afterPropertiesSet(); when(jdbcTemplate.queryForObject(determinator.getSql(), Integer.class)).thenThrow(new DataRetrievalFailureException("")); determinator.determineHistoryLevel(); }
Example #13
Source File: AutomationUtil.java From webanno with Apache License 2.0 | 5 votes |
/** * Repeat annotation will repeat annotations of same pattern to all documents on the project * load CAS from document in case no initial CORRECTION_CAS is not created before */ public static void loadDocument(SourceDocument aDocument, AnnotationSchemaService annotationService, DocumentService aDocumentService, CorrectionDocumentService aCorrectionDocumentService, User logedInUser) throws UIMAException, ClassNotFoundException, IOException, AnnotationException { CAS cas = null; if (!aCorrectionDocumentService.existsCorrectionCas(aDocument)) { try { AnnotationDocument logedInUserAnnotationDocument = aDocumentService .getAnnotationDocument(aDocument, logedInUser); cas = aDocumentService.readAnnotationCas(logedInUserAnnotationDocument); annotationService.upgradeCas(cas, logedInUserAnnotationDocument); aCorrectionDocumentService.writeCorrectionCas(cas, aDocument); } catch (DataRetrievalFailureException | NoResultException e) { cas = aDocumentService.readAnnotationCas( aDocumentService.createOrGetAnnotationDocument(aDocument, logedInUser)); // upgrade this cas annotationService.upgradeCas(cas, aDocumentService.createOrGetAnnotationDocument(aDocument, logedInUser)); aCorrectionDocumentService.writeCorrectionCas(cas, aDocument); } } else { cas = aCorrectionDocumentService.readCorrectionCas(aDocument); // upgrade this automation cas aCorrectionDocumentService.upgradeCorrectionCas(cas, aDocument); } }
Example #14
Source File: CasStorageServiceImpl.java From webanno with Apache License 2.0 | 5 votes |
/** * Runs {@link CasDoctor} in repair mode on the given CAS (if repairs are active), otherwise * it runs only in analysis mode. * <p> * <b>Note:</b> {@link CasDoctor} is an optional service. If no {@link CasDoctor} implementation * is available, this method returns without doing anything. * * @param aProject * the project * @param aDocumentName * the document name (used for logging) * @param aDocumentId * the aDocument ID (used for logging) * @param aUsername * the user owning the CAS (used for logging) * @param aCas * the CAS object */ private void analyzeAndRepair(Project aProject, String aDocumentName, long aDocumentId, String aUsername, CAS aCas) { if (casDoctor == null) { return; } // Check if repairs are active - if this is the case, we only need to run the repairs // because the repairs do an analysis as a pre- and post-condition. if (casDoctor.isRepairsActive()) { try { casDoctor.repair(aProject, aCas); } catch (Exception e) { throw new DataRetrievalFailureException("Error repairing CAS of user [" + aUsername + "] for document [" + aDocumentName + "] (" + aDocumentId + ") in project[" + aProject.getName() + "] (" + aProject.getId() + ")", e); } } // If the repairs are not active, then we run the analysis explicitly else { analyze(aProject, aDocumentName, aDocumentId, aUsername, aCas); } }
Example #15
Source File: AutomationCasStorageServiceImpl.java From webanno with Apache License 2.0 | 5 votes |
@Override public CAS readCas(TrainingDocument aDocument) throws IOException { log.debug("Reading CAs for Automation document [{}] ({}) in project [{}] ({})", aDocument.getName(), aDocument.getId(), aDocument.getProject().getName(), aDocument.getProject().getId()); // DebugUtils.smallStack(); synchronized (lock) { File annotationFolder = getAutomationFolder(aDocument); String file = aDocument.getName() + ".ser"; try { File serializedCasFile = new File(annotationFolder, file); if (!serializedCasFile.exists()) { throw new FileNotFoundException("Annotation document of Training document " + "[" + aDocument.getName() + "] (" + aDocument.getId() + ") not found in project[" + aDocument.getProject().getName() + "] (" + aDocument.getProject().getId() + ")"); } CAS cas = CasCreationUtils.createCas((TypeSystemDescription) null, null, null); CasPersistenceUtils.readSerializedCas(cas, serializedCasFile); analyzeAndRepair(aDocument, cas); return cas; } catch (UIMAException e) { throw new DataRetrievalFailureException("Unable to parse annotation", e); } } }
Example #16
Source File: KeyHolderTests.java From effectivejava with Apache License 2.0 | 5 votes |
public void testSingleKeyNonNumeric(){ List<Map<String, Object>> l = new LinkedList<Map<String, Object>>(); Map<String, Object> m = new HashMap<String, Object>(1); m.put("key", "1"); l.add(m); kh.getKeyList().addAll(l); try { kh.getKey().intValue(); } catch (DataRetrievalFailureException e) { assertTrue(e.getMessage().startsWith("The generated key is not of a supported numeric type.")); } }
Example #17
Source File: SqlMapSequenceDao.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * This is a generic sequence ID generator that is based on a database * table called 'SEQUENCE', which contains two columns (NAME, NEXTID). * This approach should work with any database. * @param name the name of the sequence * @return the next ID */ public int getNextId(String name) throws DataAccessException { Sequence sequence = new Sequence(name, -1); sequence = (Sequence) getSqlMapClientTemplate().queryForObject("getSequence", sequence); if (sequence == null) { throw new DataRetrievalFailureException( "Could not get next value of sequence '" + name + "': sequence does not exist"); } Object parameterObject = new Sequence(name, sequence.getNextId() + 1); getSqlMapClientTemplate().update("updateSequence", parameterObject, 1); return sequence.getNextId(); }
Example #18
Source File: RestServiceExceptionMapper.java From cxf-fediz with Apache License 2.0 | 5 votes |
@Override public Response toResponse(final Exception ex) { LOG.warn("Exception occured processing REST request: " + ex.getMessage(), ex); if (ex instanceof AccessDeniedException) { return Response.status(Response.Status.UNAUTHORIZED). header(HttpHeaders.WWW_AUTHENTICATE, BASIC_REALM_UNAUTHORIZED). build(); } if (ex instanceof ConstraintViolationException) { ConstraintViolationException cve = (ConstraintViolationException)ex; LOG.debug("{}\n{}", ex.getMessage(), cve.getConstraintViolations().toString()); return buildResponse(Response.Status.BAD_REQUEST, ex); } if (ex instanceof DataIntegrityViolationException) { return buildResponse(Response.Status.CONFLICT, ex); } if (ex instanceof EmptyResultDataAccessException) { return buildResponse(Response.Status.NOT_FOUND, ex); } if (ex instanceof DataRetrievalFailureException) { return buildResponse(Response.Status.NOT_FOUND, ex); } // Rest is interpreted as InternalServerError return buildResponse(Response.Status.INTERNAL_SERVER_ERROR, ex); }
Example #19
Source File: PipelineSqlMapDao.java From gocd with Apache License 2.0 | 5 votes |
@Override public Pipeline pipelineWithMaterialsAndModsByBuildId(long buildId) { String cacheKey = this.cacheKeyGenerator.generate("getPipelineByBuildId", buildId); return pipelineByBuildIdCache.get(cacheKey, new Supplier<Pipeline>() { @Override public Pipeline get() { Pipeline pipeline = (Pipeline) getSqlMapClientTemplate().queryForObject("getPipelineByBuildId", buildId); if (pipeline == null) { throw new DataRetrievalFailureException("Could not load pipeline from build with id " + buildId); } return loadMaterialRevisions(pipeline); } }); }
Example #20
Source File: PipelineSqlMapDao.java From gocd with Apache License 2.0 | 5 votes |
@Override public Pipeline pipelineByIdWithMods(long pipelineId) { Pipeline pipeline = (Pipeline) getSqlMapClientTemplate().queryForObject("pipelineById", pipelineId); if (pipeline == null) { throw new DataRetrievalFailureException("Could not load pipeline with id " + pipelineId); } return loadMaterialRevisions(pipeline); }
Example #21
Source File: JobInstanceSqlMapDao.java From gocd with Apache License 2.0 | 5 votes |
private JobInstance job(long buildId, String queryName) { JobInstance instance = (JobInstance) getSqlMapClientTemplate().queryForObject(queryName, buildId); if (instance == null) { throw new DataRetrievalFailureException("Could not load build with id " + buildId); } if (instance.getIdentifier() == null) { throw new RuntimeException("Identifier must not be null!"); } return instance; }
Example #22
Source File: StageSqlMapDao.java From gocd with Apache License 2.0 | 5 votes |
@Override public Stage getStageByBuild(long buildId) { Stage stage = (Stage) getSqlMapClientTemplate().queryForObject("getStageByBuildId", buildId); if (stage == null) { throw new DataRetrievalFailureException("Unable to load related stage data for buildId " + buildId); } return stage; }
Example #23
Source File: SimpleDbOperationRetrierTest.java From spring-data-simpledb with MIT License | 5 votes |
@Test(expected = DataRetrievalFailureException.class) public void executeWithRetries_should_translate_unrecognized_exceptions() { AbstractServiceUnavailableOperationRetrier retrier = new AbstractServiceUnavailableOperationRetrier(SERVICE_UNAVAILABLE_RETRIES) { @Override public void execute() { throw new ResourceNotFoundException("Test Mapping"); } }; retrier.executeWithRetries(); }
Example #24
Source File: AbstractJcrDao.java From nextreports-server with Apache License 2.0 | 5 votes |
protected Node checkId(String id) throws NotFoundException { // TODO improve try { return getTemplate().getNodeByUUID(id); } catch (DataRetrievalFailureException e) { if (e.getCause() instanceof ItemNotFoundException) { throw new NotFoundException("Id '" + id + "' not found"); } throw e; } }
Example #25
Source File: HistoryLevelDeterminatorJdbcTemplateImplTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void determinedExceptionIgnoringTest() throws Exception { HistoryLevelDeterminatorJdbcTemplateImpl determinator = new HistoryLevelDeterminatorJdbcTemplateImpl(); final String defaultHistoryLevel = "test"; determinator.setDefaultHistoryLevel(defaultHistoryLevel); determinator.setJdbcTemplate(jdbcTemplate); determinator.setCamundaBpmProperties(camundaBpmProperties); determinator.afterPropertiesSet(); when(jdbcTemplate.queryForObject(determinator.getSql(), Integer.class)).thenThrow(new DataRetrievalFailureException("")); String determineHistoryLevel = determinator.determineHistoryLevel(); assertEquals(determinator.defaultHistoryLevel, determineHistoryLevel); verify(jdbcTemplate).queryForObject(determinator.getSql(), Integer.class); }
Example #26
Source File: HistoryLevelDeterminatorJdbcTemplateImplTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test(expected = DataRetrievalFailureException.class) public void determinedExceptionNotIgnoringTest() throws Exception { HistoryLevelDeterminatorJdbcTemplateImpl determinator = new HistoryLevelDeterminatorJdbcTemplateImpl(); determinator.setIgnoreDataAccessException(false); final String defaultHistoryLevel = "test"; determinator.setDefaultHistoryLevel(defaultHistoryLevel); determinator.setJdbcTemplate(jdbcTemplate); determinator.setCamundaBpmProperties(camundaBpmProperties); determinator.afterPropertiesSet(); when(jdbcTemplate.queryForObject(determinator.getSql(), Integer.class)).thenThrow(new DataRetrievalFailureException("")); determinator.determineHistoryLevel(); }
Example #27
Source File: CciLocalTransactionTests.java From java-technology-stack with MIT License | 5 votes |
/** * Test if a transaction ( begin / rollback ) is executed on the * LocalTransaction when CciLocalTransactionManager is specified as * transaction manager and a non-checked exception is thrown. */ @Test public void testLocalTransactionRollback() throws ResourceException { final ConnectionFactory connectionFactory = mock(ConnectionFactory.class); Connection connection = mock(Connection.class); Interaction interaction = mock(Interaction.class); LocalTransaction localTransaction = mock(LocalTransaction.class); final Record record = mock(Record.class); final InteractionSpec interactionSpec = mock(InteractionSpec.class); given(connectionFactory.getConnection()).willReturn(connection); given(connection.getLocalTransaction()).willReturn(localTransaction); given(connection.createInteraction()).willReturn(interaction); given(interaction.execute(interactionSpec, record, record)).willReturn(true); given(connection.getLocalTransaction()).willReturn(localTransaction); CciLocalTransactionManager tm = new CciLocalTransactionManager(); tm.setConnectionFactory(connectionFactory); TransactionTemplate tt = new TransactionTemplate(tm); try { tt.execute(new TransactionCallback<Void>() { @Override public Void doInTransaction(TransactionStatus status) { assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(connectionFactory)); CciTemplate ct = new CciTemplate(connectionFactory); ct.execute(interactionSpec, record, record); throw new DataRetrievalFailureException("error"); } }); } catch (Exception ex) { } verify(localTransaction).begin(); verify(interaction).close(); verify(localTransaction).rollback(); verify(connection).close(); }
Example #28
Source File: MappingCommAreaOperation.java From spring-analysis-note with MIT License | 5 votes |
@Override protected final Object extractOutputData(Record record) throws DataAccessException { CommAreaRecord commAreaRecord = (CommAreaRecord) record; try { return bytesToObject(commAreaRecord.toByteArray()); } catch (IOException ex) { throw new DataRetrievalFailureException("I/O exception during bytes conversion", ex); } }
Example #29
Source File: CciLocalTransactionTests.java From spring-analysis-note with MIT License | 5 votes |
/** * Test if a transaction ( begin / rollback ) is executed on the * LocalTransaction when CciLocalTransactionManager is specified as * transaction manager and a non-checked exception is thrown. */ @Test public void testLocalTransactionRollback() throws ResourceException { final ConnectionFactory connectionFactory = mock(ConnectionFactory.class); Connection connection = mock(Connection.class); Interaction interaction = mock(Interaction.class); LocalTransaction localTransaction = mock(LocalTransaction.class); final Record record = mock(Record.class); final InteractionSpec interactionSpec = mock(InteractionSpec.class); given(connectionFactory.getConnection()).willReturn(connection); given(connection.getLocalTransaction()).willReturn(localTransaction); given(connection.createInteraction()).willReturn(interaction); given(interaction.execute(interactionSpec, record, record)).willReturn(true); given(connection.getLocalTransaction()).willReturn(localTransaction); CciLocalTransactionManager tm = new CciLocalTransactionManager(); tm.setConnectionFactory(connectionFactory); TransactionTemplate tt = new TransactionTemplate(tm); try { tt.execute(new TransactionCallback<Void>() { @Override public Void doInTransaction(TransactionStatus status) { assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(connectionFactory)); CciTemplate ct = new CciTemplate(connectionFactory); ct.execute(interactionSpec, record, record); throw new DataRetrievalFailureException("error"); } }); } catch (Exception ex) { } verify(localTransaction).begin(); verify(interaction).close(); verify(localTransaction).rollback(); verify(connection).close(); }
Example #30
Source File: GeneratedKeyHolder.java From spring-analysis-note with MIT License | 5 votes |
@Override @Nullable public Number getKey() throws InvalidDataAccessApiUsageException, DataRetrievalFailureException { if (this.keyList.isEmpty()) { return null; } if (this.keyList.size() > 1 || this.keyList.get(0).size() > 1) { throw new InvalidDataAccessApiUsageException( "The getKey method should only be used when a single key is returned. " + "The current key entry contains multiple keys: " + this.keyList); } Iterator<Object> keyIter = this.keyList.get(0).values().iterator(); if (keyIter.hasNext()) { Object key = keyIter.next(); if (!(key instanceof Number)) { throw new DataRetrievalFailureException( "The generated key is not of a supported numeric type. " + "Unable to cast [" + (key != null ? key.getClass().getName() : null) + "] to [" + Number.class.getName() + "]"); } return (Number) key; } else { throw new DataRetrievalFailureException("Unable to retrieve the generated key. " + "Check that the table has an identity column enabled."); } }