Skip to content

Instantly share code, notes, and snippets.

@yagop
Created May 13, 2014 22:32
Show Gist options
  • Save yagop/d627edc54d2ba35337b8 to your computer and use it in GitHub Desktop.
Save yagop/d627edc54d2ba35337b8 to your computer and use it in GitHub Desktop.
package com.tvmanager.greendaogen;
import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;
import de.greenrobot.daogenerator.ToMany;
public class TVManager {
public static void main(String[] args) throws Exception {
Schema esquema = new Schema(4, "com.tvmanager.sql");
esquema.enableKeepSectionsByDefault();
addCabeceraPedido(esquema);
new DaoGenerator().generateAll(esquema, "../TVManager/src");
}
/**
* @param esquema
*/
private static void addCabeceraPedido(Schema esquema) {
Entity tvShow = esquema.addEntity("Tvshow");
//tvShow.addIdProperty();
tvShow.addLongProperty("tvdb_id").primaryKey();
tvShow.addBooleanProperty("following");
tvShow.addBooleanProperty("finished");
tvShow.addStringProperty("title");
tvShow.addStringProperty("year");
tvShow.addStringProperty("url");
tvShow.addStringProperty("banner");
tvShow.addStringProperty("country");
tvShow.addStringProperty("overview");
tvShow.addStringProperty("runtime");
tvShow.addStringProperty("network");
tvShow.addStringProperty("air_day");
tvShow.addStringProperty("air_time");
Entity episode = esquema.addEntity("Tvepisode");
episode.addIdProperty().primaryKey();
episode.addIntProperty("season_number").notNull();
episode.addIntProperty("episode_number").notNull();
episode.addBooleanProperty("watched");
Property tvshowId = episode.addLongProperty("tvshowId").notNull().getProperty();
// One episode belongs to one show
episode.addToOne(tvShow, tvshowId);
// One show have many episodes
ToMany tvShowToEpisode = tvShow.addToMany(episode, tvshowId);
tvShowToEpisode.setName("tvepisodes");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment