Package er.cayenne.example.persistent.auto

Source Code of er.cayenne.example.persistent.auto._Gallery

package er.cayenne.example.persistent.auto;

import java.util.List;

import org.apache.cayenne.ObjectContext;
import org.apache.cayenne.exp.Expression;
import org.apache.cayenne.query.Ordering;
import org.apache.cayenne.query.SelectQuery;

import er.cayenne.CayenneObject;
import er.cayenne.example.Key;
import er.cayenne.example.persistent.Gallery;
import er.cayenne.example.persistent.Painting;

/**
* Class _Gallery was generated by Cayenne.
* It is probably a good idea to avoid changing this class manually,
* since it may be overwritten next time code is regenerated.
* If you need to make any customizations, please use subclass.
*/
public abstract class _Gallery extends CayenneObject {

    public static final String ENTITY_NAME = "Gallery";

    public static final Key NAME = new Key("name");
    public static final Key PAINTINGS = new Key("paintings");

    public static final String NAME_KEY = "name";
    public static final String PAINTINGS_KEY = "paintings";

    public static final String ID_PK_COLUMN = "ID";

  public static Gallery createGallery(ObjectContext ec
    , String name
  ) {
    Gallery result = new Gallery();
    ec.registerNewObject(result);
    result.setName(name);
    return result;
  }
 
    public void setName(String name) {
        writeProperty("name", name);
    }
    public String name() {
        return (String)readProperty("name");
    }

    public void addToPaintings(Painting obj) {
        addToManyTarget("paintings", obj, true);
    }
    public void removeFromPaintings(Painting obj) {
        removeToManyTarget("paintings", obj, true);
    }
    public Painting createPaintingsRelationship() {
      Painting obj = getObjectContext().newObject(Painting.class);
        addToManyTarget("paintings", obj, true);
        return obj;
    }
    public void deletePaintingsRelationship(Painting obj) {
        removeToManyTarget("paintings", obj, true);
        getObjectContext().deleteObject(obj);
    }
    @SuppressWarnings("unchecked")
    public List<Painting> paintings() {
        return (List<Painting>)readProperty("paintings");
    }
   
    public List<Painting> paintings(Expression expression) {
    return expression.filterObjects(paintings());
  }



  @SuppressWarnings("unchecked")
  public static java.util.List<Gallery> fetchAll( ObjectContext oc ) {
    SelectQuery q = new SelectQuery( Gallery.class );
      return oc.performQuery( q );
   }
  
  @SuppressWarnings("unchecked")
   public static java.util.List<Gallery> fetch( ObjectContext oc, Expression expression ) {
      SelectQuery q = new SelectQuery( Gallery.class, expression );
      return oc.performQuery( q );
   }

  @SuppressWarnings("unchecked")
   public static java.util.List<Gallery> fetch( ObjectContext oc, Expression expression, java.util.List<Ordering> orderings ) {
      SelectQuery q = new SelectQuery( Gallery.class, expression );

      if ( orderings != null ) {
         for( Ordering ordering : orderings ) {
          q.addOrdering( ordering );
         }
      }

      return oc.performQuery( q );
   }
  
   @SuppressWarnings("unchecked")
   public static java.util.List<Gallery> fetchAll( ObjectContext oc, java.util.List<Ordering> orderings ) {
      SelectQuery q = new SelectQuery( Gallery.class);

      if ( orderings != null ) {
         for( Ordering ordering : orderings ) {
          q.addOrdering( ordering );
         }
      }

      return oc.performQuery( q );
   }
  
  
  public static Gallery fetchOne(ObjectContext oc, Expression expression) {
    java.util.List<Gallery> objects = fetch(oc, expression);
    Gallery obj;
    int count = objects.size();
    if (count == 0) {
      obj = null;
    } else if (count == 1) {
      obj = objects.get(0);
    } else {
      throw new IllegalStateException("There was more than one Gallery that matched the qualifier '" + expression + "'.");
    }
    return obj;
  }
}
TOP

Related Classes of er.cayenne.example.persistent.auto._Gallery

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.