| package org.apache.cayenne.example.persistent.auto; |
| |
| import java.io.IOException; |
| import java.io.ObjectInputStream; |
| import java.io.ObjectOutputStream; |
| import java.util.List; |
| |
| import org.apache.cayenne.BaseDataObject; |
| import org.apache.cayenne.example.persistent.Painting; |
| import org.apache.cayenne.exp.Property; |
| |
| /** |
| * Class _Artist 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 _Artist extends BaseDataObject { |
| |
| private static final long serialVersionUID = 1L; |
| |
| public static final String ID_PK_COLUMN = "ID"; |
| |
| public static final Property<String> ARTIST_NAME = Property.create("artistName", String.class); |
| public static final Property<List<Painting>> PAINTINGS = Property.create("paintings", List.class); |
| |
| protected String artistName; |
| |
| protected Object paintings; |
| |
| public void setArtistName(String artistName) { |
| beforePropertyWrite("artistName", this.artistName, artistName); |
| this.artistName = artistName; |
| } |
| |
| public String getArtistName() { |
| beforePropertyRead("artistName"); |
| return this.artistName; |
| } |
| |
| public void addToPaintings(Painting obj) { |
| addToManyTarget("paintings", obj, true); |
| } |
| |
| public void removeFromPaintings(Painting obj) { |
| removeToManyTarget("paintings", obj, true); |
| } |
| |
| @SuppressWarnings("unchecked") |
| public List<Painting> getPaintings() { |
| return (List<Painting>)readProperty("paintings"); |
| } |
| |
| @Override |
| public Object readPropertyDirectly(String propName) { |
| if(propName == null) { |
| throw new IllegalArgumentException(); |
| } |
| |
| switch(propName) { |
| case "artistName": |
| return this.artistName; |
| case "paintings": |
| return this.paintings; |
| default: |
| return super.readPropertyDirectly(propName); |
| } |
| } |
| |
| @Override |
| public void writePropertyDirectly(String propName, Object val) { |
| if(propName == null) { |
| throw new IllegalArgumentException(); |
| } |
| |
| switch (propName) { |
| case "artistName": |
| this.artistName = (String)val; |
| break; |
| case "paintings": |
| this.paintings = val; |
| break; |
| default: |
| super.writePropertyDirectly(propName, val); |
| } |
| } |
| |
| private void writeObject(ObjectOutputStream out) throws IOException { |
| writeSerialized(out); |
| } |
| |
| private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { |
| readSerialized(in); |
| } |
| |
| @Override |
| protected void writeState(ObjectOutputStream out) throws IOException { |
| super.writeState(out); |
| out.writeObject(this.artistName); |
| out.writeObject(this.paintings); |
| } |
| |
| @Override |
| protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException { |
| super.readState(in); |
| this.artistName = (String)in.readObject(); |
| this.paintings = in.readObject(); |
| } |
| |
| } |