347348349350351352353354355356357
try { Object id = idField.get(ctx.getInstance()); // Check exist if (getFile(id).exists()) throw new DuplicateKeyException("Already exists: "+id); // Store to file storeEntity(id, ctx.getInstance()); return id;
128129130131132133134135136137138
} catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() +
226227228229230231232233234235236
try { stmt.setInt(1, id); ResultSet rs = stmt.executeQuery(); try { if (rs.next()) throw new DuplicateKeyException("EntityExc id " + pk.intValue() + " already in database."); } finally { rs.close(); } } finally {
102103104105106107108109110
{ } } if (dublicate) throw new DuplicateKeyException ("Bean with id="+_id+" already exists."); return id; }
154155156157158159160161162
108109110111112113114115116117118
ps.setString(1, pk.getKey()); ResultSet rs = ps.executeQuery(); if (rs.next()) throw new DuplicateKeyException("Bean with accountNumber=" + pk.getKey() + " already exists."); } finally {
198199200201202203204205206207
log(error); throw new CreateException (error); } String error = "An Account already exists in the database with Primary Key " + accountId; log(error); throw new DuplicateKeyException(error); } finally { cleanup(con, ps); } }
205206207208209210211212213214
325326327328329330331
String msg = I18NHelper.getMessage(cmpMessages, "GEN.ejbcreate_exception_dup", beanName, // NOI18N findCallingMethodName(), paramList); cmpLifecycleLogger.log(Logger.FINER, msg, ex); throw new DuplicateKeyException(msg); }
8283848586878889909192
rs = ps.executeQuery(); if (!rs.next()) { throw new CreateException("Error checking if entity with primary pk " + pk + "exists: SQL returned no rows"); } if (rs.getInt(1) > 0) { throw new DuplicateKeyException("Entity with primary key " + pk + " already exists"); } } catch (SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); } finally {