Пример #1
0
 /**
  * Get all objects as a list.
  *
  * @return list of all objects or an empty list if none exist.
  * @see #findByKey(Object)
  * @see #getAllAsMap()
  */
 public List getAllAsList() {
   AbstractDomain domain = getDomain(searchDomainClassName);
   try {
     return domain.findAll();
   } finally {
     releaseDomain(domain);
   }
 }
Пример #2
0
 /**
  * Creates embedded <code>PersistentObject</code>.
  *
  * @return new instance of the embedded <code>PersistentObject</code>
  */
 public PersistentObject newPersistentObject() {
   AbstractDomain domain = getDomain(fullDomainClassName);
   try {
     return domain.newPersistentObject();
   } finally {
     releaseDomain(domain);
   }
 }
Пример #3
0
 /**
  * Finds by a specific where/clause order by parameter. This method simply wraps a poolable
  * searchable <code>AbstractDomain.findWhereOrderBy()</code> method.
  *
  * @param whereClause where clause
  * @param orderByClause Description of the Parameter
  * @return a list of objects that meet critieria. An empty list will be returned if no objects
  *     match.
  * @see net.sf.jrf.domain.AbstractDomain#findWhereOrderBy(String,String)
  */
 public List findWhereOrderBy(String whereClause, String orderByClause) {
   AbstractDomain domain = getDomain(searchDomainClassName);
   try {
     return domain.findWhereOrderBy(whereClause, orderByClause);
   } finally {
     releaseDomain(domain);
   }
 }
Пример #4
0
 /**
  * Returns a list of embedded <code>PersistentObject</code> class property names in this object.
  *
  * @return a list of embedded property names in this object. An empty list will be returned if no
  *     embedded <code>PersistentObject</code> class names exist.
  * @see #newEmbeddedPersistentObject(PersistentObject,String)
  */
 public List getEmbeddedPropertyNames() {
   AbstractDomain domain = getDomain(fullDomainClassName);
   try {
     return domain.getEmbeddedPropertyNames();
   } finally {
     releaseDomain(domain);
   }
 }
Пример #5
0
 /**
  * Copies keys from the master object to the embedded detail object.
  *
  * @param master <code>PersistentObject</code> instance that <em>must</em> be the parent record of
  *     <code>className</code> object. For simple two-level composites, this value will be the type
  *     returned by <code>newPersistentObject</code>.
  * @param embedded embedded <code>PersistentObject</code> instance to populate.
  * @param beanProperty bean name of accessor in <code>PersistentObject</code> to instantiate.
  * @throws IllegalArgumentException if class name of <code>embedded</code> is invalid.
  * @throws ClassCastException if <code>master</code> is not the appropriate class type.
  */
 public void populateEmbeddedObjectKeyValues(
     PersistentObject master, PersistentObject embedded, String beanProperty) {
   AbstractDomain domain = getDomain(fullDomainClassName);
   try {
     domain.populateEmbeddedObjectKeyValues(master, embedded, beanProperty);
   } finally {
     releaseDomain(domain);
   }
 }
Пример #6
0
 /**
  * Creates new embedded <code>PersistentObject</code>.
  *
  * @param master <code>PersistentObject</code> instance that <em>must</em> be the parent record of
  *     <code>className</code> object. For simple two-level composites, this value will be the type
  *     returned by <code>newPersistentObject</code>.
  * @param beanProperty bean name of <code>PersistentObject</code> to instantiate.
  * @return new instance of the embedded <code>PersistentObject</code>
  * @throws IllegalArgumentException if class name is invalid.
  * @throws ClassCastException if <code>master</code> is not the appropriate class type.
  * @see net.sf.jrf.domain.AbstractDomain#newEmbeddedPersistentObject(PersistentObject,String)
  * @see net.sf.jrf.domain.EmbeddedPersistentObjectHandler#getBeanAttribute()
  */
 public PersistentObject newEmbeddedPersistentObject(
     PersistentObject master, String beanProperty) {
   AbstractDomain domain = getDomain(fullDomainClassName);
   try {
     return domain.newEmbeddedPersistentObject(master, beanProperty);
   } finally {
     releaseDomain(domain);
   }
 }
Пример #7
0
 /**
  * Updates a <code>PersistentObject</code> instance, in many cases one fetched through a call to
  * <code>findByKey()</code>.
  *
  * @param persistentObject object to save.
  * @exception ObjectHasChangedException Description of the Exception
  * @exception MissingAttributeException Description of the Exception
  * @throws ObjectHasChangeException when another user has already updated the record (i.e. an
  *     optimistic lock error.
  * @throws MissingAtributeException if the column specification for some fields are marked as
  *     required and these fields are <code>null</code> in the <code>PersistentObject</code>
  *     parameter.
  * @throws DuplicateRowException if an insert operation fails or would fail because of key
  *     duplication.
  * @throws InvalidValueException if a value in a column is invalid (e.g. out of range).
  * @see #findByKey(Object)
  */
 public void update(PersistentObject persistentObject)
     throws ObjectHasChangedException, MissingAttributeException, DuplicateRowException,
         InvalidValueException {
   AbstractDomain domain = getDomain(fullDomainClassName);
   try {
     domain.update(persistentObject);
   } finally {
     releaseDomain(domain);
   }
 }
Пример #8
0
 /**
  * Get all objects as a map.
  *
  * @return list of all objects or an empty list if none exist.
  * @see #findByKey(Object)
  * @see #getAllAsList()
  */
 public Map getAllAsMap() {
   AbstractDomain domain = getDomain(searchDomainClassName);
   try {
     ApplicationRowHandlerHashMap map = new ApplicationRowHandlerHashMap();
     domain.findAll(map);
     return (Map) map.getResult();
   } finally {
     releaseDomain(domain);
   }
 }
Пример #9
0
 /**
  * Fetches a specific object or object graph, in many cases one fetched through a call to <code>
  * getAllAsList()</code> or <code>getAllAsMap()</code>.
  *
  * @param key object key.
  * @return object under given key or <code>null</code> if not found.
  * @see #getAllAsList()
  * @see #getAllAsMap()
  */
 public PersistentObject findByKey(Object key) {
   AbstractDomain domain = getDomain(fullDomainClassName);
   try {
     // If a string decode to binary.
     if (key instanceof String) {
       key = domain.decodePrimaryKey((String) key);
     }
     return domain.find(key);
   } finally {
     releaseDomain(domain);
   }
 }
Пример #10
0
 /** Finds by a specific prepared find statement by wrapping the poolable search
  *<code>AbstractDomain.findByPreparedStatement</code> method.  Sub-classes must create the key.
  * @param preparedStatementKey       key added in <code>addPreparedFindStatement()</code>.
  * @param handler                    <code>ApplicationRowHandler</code> to use.
  * @param params                     list of object parameters to use to set up <code>PreparedStatment</code>.
  * @param useSearchDomain        If <code>true</code>, <code>searchClassDomainClassName</code> will be
  *                   used. Otherwise, <code>fullDomainClassName will be used.
  * @return                           number of rows fetched.
  * @throws IllegalArgumentException  if number of parameters in <code>params</code> does not
  * match number of column specifications set in <code>addPreparedFindStatement()</code>.
  * @see                              net.sf.jrf.domain.AbstractDomain#findByPreparedStatement(String,ApplicationRowHandler,List)
  */
 protected int findByPreparedStatement(
     String preparedStatementKey,
     ApplicationRowHandler handler,
     List params,
     boolean useSearchDomain) {
   AbstractDomain domain =
       getDomain(useSearchDomain ? searchDomainClassName : fullDomainClassName);
   try {
     return domain.findByPreparedStatement(preparedStatementKey, handler, params);
   } finally {
     releaseDomain(domain);
   }
 }
Пример #11
0
 /**
  * Deletes a <code>PersistentObject</code> instance, in many cases one fetched through a call to
  * <code>findByKey()</code>.
  *
  * @param persistentObject object to delete.
  * @param ignoreChangedException If <code>true</code>, <code>ObjectHasChangedException</code> will
  *     not be thrown, but ignored.
  * @throws ObjectHasChangeException when another user has already delete the record (i.e. an
  *     optimistic lock error) and <code>ignoreChangedException</code> is <code>false</code>.
  * @see #findByKey(Object)
  * @see #getAllAsList()
  */
 public void delete(PersistentObject persistentObject, boolean ignoreChangedException)
     throws ObjectHasChangedException {
   AbstractDomain domain = getDomain(fullDomainClassName);
   PersistentObject objectToDelete = persistentObject;
   try {
     if (!fullDomainClassName.equals(searchDomainClassName)) {
       // May have to fetch the composite object.
       objectToDelete = domain.find(persistentObject);
       if (objectToDelete == null) {
         throw new ObjectHasChangedException(persistentObject);
       } // Handle race condition.
     }
     domain.delete(objectToDelete);
   } catch (ObjectHasChangedException oe) {
     if (!ignoreChangedException) throw oe;
   } catch (Exception ex) {
     if (ex instanceof DatabaseException) throw (DatabaseException) ex;
     throw new DatabaseException(ex, "Unexpected delete exception");
   } finally {
     releaseDomain(domain);
   }
 }