Examples of DuplicateKeyException


Examples of javax.ejb.DuplicateKeyException

               ps.setString(1, pk.getKey());

               ResultSet rs = ps.executeQuery();

               if (rs.next())
                  throw new DuplicateKeyException("Bean with accountNumber=" +
                     pk.getKey() +
                     " already exists.");
            }
            finally
            {
View Full Code Here

Examples of javax.ejb.DuplicateKeyException

        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);
    }
  }
View Full Code Here

Examples of javax.ejb.DuplicateKeyException

        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);
    }
  }
View Full Code Here

Examples of javax.ejb.DuplicateKeyException

        String msg = I18NHelper.getMessage(cmpMessages,
            "GEN.ejbcreate_exception_dup", beanName, // NOI18N
            findCallingMethodName(), paramList);

        cmpLifecycleLogger.log(Logger.FINER, msg, ex);
        throw new DuplicateKeyException(msg);
    }
View Full Code Here

Examples of javax.ejb.DuplicateKeyException

                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 {
View Full Code Here

Examples of javax.ejb.DuplicateKeyException

            // insert-after-ejb-post-create
            try {
                pctx.flush();
            } catch (SQLException e) {
                if ("23000".equals(e.getSQLState())) {
                    throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getPrimaryKey());
                } else {
                    throw new CreateException("Failed to create instance: pk=" +
                            ctx.getPrimaryKey() +
                            ", state=" +
                            e.getSQLState() +
View Full Code Here

Examples of javax.ejb.DuplicateKeyException

            // insert-after-ejb-post-create
            try {
                pctx.flush();
            } catch (SQLException e) {
                if ("23000".equals(e.getSQLState())) {
                    throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getPrimaryKey());
                } else {
                    throw new CreateException("Failed to create instance: pk=" + ctx.getPrimaryKey() +
                            ", state=" + e.getSQLState() +
                            ", msg=" + e.getMessage());
                }
View Full Code Here

Examples of javax.ejb.DuplicateKeyException

            // insert-after-ejb-post-create
            try {
                pctx.flush();
            } catch (SQLException e) {
                if ("23000".equals(e.getSQLState())) {
                    throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getPrimaryKey());
                } else {
                    throw new CreateException("Failed to create instance: pk=" +
                            ctx.getPrimaryKey() +
                            ", state=" +
                            e.getSQLState() +
View Full Code Here

Examples of javax.ejb.DuplicateKeyException

            {
               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);
View Full Code Here

Examples of javax.ejb.DuplicateKeyException

      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;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.