Package er.cayenne.example.persistent.auto

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

package er.cayenne.example.persistent.auto;

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.Artist;
import er.cayenne.example.persistent.Gallery;
import er.cayenne.example.persistent.Painting;

/**
* Class _Painting 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 _Painting extends CayenneObject {

    public static final String ENTITY_NAME = "Painting";

    public static final Key NAME = new Key("name");
    public static final Key ARTIST = new Key("artist");
    public static final Key GALLERY = new Key("gallery");

    public static final String NAME_KEY = "name";
    public static final String ARTIST_KEY = "artist";
    public static final String GALLERY_KEY = "gallery";

    public static final String ID_PK_COLUMN = "ID";

  public static Painting createPainting(ObjectContext ec
    , String name
  ) {
    Painting result = new Painting();
    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 setArtist(Artist artist) {
        setToOneTarget("artist", artist, true);
    }
    public Artist createArtistRelationship() {
        Artist obj = getObjectContext().newObject(Artist.class);
        setToOneTarget("artist", obj, true);
        return obj;
    }

    public Artist artist() {
        return (Artist)readProperty("artist");
    }


    public void setGallery(Gallery gallery) {
        setToOneTarget("gallery", gallery, true);
    }
    public Gallery createGalleryRelationship() {
        Gallery obj = getObjectContext().newObject(Gallery.class);
        setToOneTarget("gallery", obj, true);
        return obj;
    }

    public Gallery gallery() {
        return (Gallery)readProperty("gallery");
    }



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

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

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

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

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

      return oc.performQuery( q );
   }
  
  
  public static Painting fetchOne(ObjectContext oc, Expression expression) {
    java.util.List<Painting> objects = fetch(oc, expression);
    Painting 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 Painting that matched the qualifier '" + expression + "'.");
    }
    return obj;
  }
}
TOP

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

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.