Package javax.persistence

Examples of javax.persistence.PersistenceException


        ServiceReference[] refs = null;       
        try {
            filter = "(osgi.unit.name="+ unitName +")";
            refs = ctx.getServiceReferences(EntityManagerFactory.class.getName(), filter);
        } catch (InvalidSyntaxException isEx) {
            new PersistenceException("Implementation error - incorrect filter specified while looking up EMF", isEx);
        }
        if ((refs != null) && (refs.length != 0)) {
            debug("Persistence class - lookupEMF, found service ", unitName, " in registry");
            // Take the first one
            return (EntityManagerFactory)ctx.getService(refs[0]);
View Full Code Here


        ServiceReference[] refs = null;       
        try {
            filter = "(osgi.unit.name="+ unitName +")";
            refs = ctx.getServiceReferences(EntityManagerFactoryBuilder.class.getName(), filter);
        } catch (InvalidSyntaxException isEx) {
            new PersistenceException("Implementation error - incorrect filter specified while looking up EMF", isEx);
        }
        if ((refs != null) && (refs.length != 0)) {
            debug("Persistence class - lookupEMFBuilder, found service ", unitName, " in registry");
            // Take the first one and create an EMF from it
            EntityManagerFactoryBuilder builder = (EntityManagerFactoryBuilder)ctx.getService(refs[0]);
View Full Code Here

        }
      }
      return bean;
     
    } catch (Exception ex) {
      throw new PersistenceException(ex);
    }
  }
View Full Code Here

      ebi.setReference(idPropertyIndex);

      return (T) eb;

    } catch (Exception ex) {
      throw new PersistenceException(ex);
    }
  }
View Full Code Here

    BeanProperty property = _findBeanProperty(propName);
    if (chain == null) {
      return property;
    }
    if (property == null) {
      throw new PersistenceException("No property found for [" + propName + "] in expression " + chain.getExpression());
    }
    if (property.containsMany()) {
      chain.setContainsMany(true);
    }
    return chain.add(property).build();
View Full Code Here

      if (pstmt != null){
        try {
          pstmt.cancel();
        } catch (SQLException e) {
          String msg = "Error cancelling query";
          throw new PersistenceException(msg, e);
        }
      }
    }
  }
View Full Code Here

    // only allow to hold simple scalar types...
    BeanDescriptor<?> targetDesc = owner.getBeanDescriptor(prop.getTargetType());
    if (targetDesc == null){
        String msg = "Could not find BeanDescriptor for "+prop.getTargetType()
            +". Perhaps the EmbeddedId class is not registered?";
        throw new PersistenceException(msg);
    }

    // deployment override information (column names)
    Map<String, String> propColMap = prop.getDeployEmbedded().getPropertyColumnMap();
View Full Code Here

            newTransaction = userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION;
            if (newTransaction) {
                userTransaction.begin();
            }
        } catch (Exception e) {
            throw new PersistenceException(e);
        }

        try {
            // Open JDBC Connection
            this.connection = dataSource.getConnection();
            if (connection == null) {
                throw new PersistenceException("The DataSource returned a null connection.");
            }
            if (connection.getAutoCommit()) {
                connection.setAutoCommit(false);
            }

        } catch (SQLException e) {
            throw new PersistenceException(e);
        }
    }
View Full Code Here

    /**
     * Commit the transaction.
     */
    public void commit() {
        if (commmitted) {
            throw new PersistenceException("This transaction has already been committed.");
        }
        try {
            try {
                if (newTransaction) {
                    userTransaction.commit();
                }
                notifyCommit();
            } finally {
                close();
            }
        } catch (Exception e) {
            throw new PersistenceException(e);
        }
        commmitted = true;
    }
View Full Code Here

                    notifyRollback(e);
                } finally {
                    closeConnection();
                }
            } catch (Exception ex) {
                throw new PersistenceException(ex);
            }
        }

    }
View Full Code Here

TOP

Related Classes of javax.persistence.PersistenceException

Copyright © 2018 www.massapicom. 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.