Package org.jboss.errai.demo.jpa.client.shared

Examples of org.jboss.errai.demo.jpa.client.shared.Genre


   * persists a selection of music from the 1960's.
   */
  private void preFillDatabaseIfEmpty() {
    TypedQuery<Album> albums = em.createNamedQuery("allAlbums", Album.class);
    if (albums.getResultList().isEmpty()) {
      Genre rock = new Genre("Rock");
      Genre soul = new Genre("Soul");
      Genre rnb = new Genre("R&B");

      Artist beatles = new Artist();
      beatles.setName("The Beatles");
      beatles.addGenre(rock);

      Artist samNDave = new Artist();
      samNDave.setName("Sam & Dave");
      samNDave.addGenre(rock);
      samNDave.addGenre(soul);
      samNDave.addGenre(rnb);

      Album album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Let It Be");
      album.setReleaseDate(new Date(11012400000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Abbey Road");
      album.setReleaseDate(new Date(-8366400000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Yellow Submarine");
      album.setReleaseDate(new Date(-30481200000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("The Beatles");
      album.setReleaseDate(new Date(-34974000000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Magical Mystery Tour");
      album.setReleaseDate(new Date(-66164400000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Sgt. Pepper's Lonely Hearts Club Band");
      album.setReleaseDate(new Date(-81633600000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Revolver");
      album.setReleaseDate(new Date(-107553600000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Rubber Soul");
      album.setReleaseDate(new Date(-128718000000L));
      em.persist(album);

      album = new Album();
      album.setArtist(samNDave);
      album.setFormat(Format.LP);
      album.setName("Hold On, I'm Comin'");
      album.setReleaseDate(new Date(-121114800000L));
      em.persist(album);

      album = new Album();
      album.setArtist(samNDave);
      album.setFormat(Format.LP);
      album.setName("Double Dynamite");
      album.setReleaseDate(new Date(-97354800000L));
      em.persist(album);

      album = new Album();
      album.setArtist(samNDave);
      album.setFormat(Format.LP);
      album.setName("Soul Men");
      album.setReleaseDate(new Date(-71092800000L));
      em.persist(album);

      // Some extra genres to play with
      em.persist(new Genre("Classical"));
      em.persist(new Genre("Country"));
      em.persist(new Genre("Folk"));
      em.persist(new Genre("Funk"));
      em.persist(new Genre("Pop"));

      // store them
      em.flush();
    }
  }
View Full Code Here


   * persists a selection of music from the 1960's.
   */
  private void preFillDatabaseIfEmpty() {
    TypedQuery<Album> albums = em.createNamedQuery("allAlbums", Album.class);
    if (albums.getResultList().isEmpty()) {
      Genre rock = new Genre("Rock");
      Genre soul = new Genre("Soul");
      Genre rnb = new Genre("R&B");

      Artist beatles = new Artist();
      beatles.setName("The Beatles");
      beatles.addGenre(rock);

      Artist samNDave = new Artist();
      samNDave.setName("Sam & Dave");
      samNDave.addGenre(rock);
      samNDave.addGenre(soul);
      samNDave.addGenre(rnb);

      Album album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Let It Be");
      album.setReleaseDate(new Date(11012400000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Abbey Road");
      album.setReleaseDate(new Date(-8366400000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Yellow Submarine");
      album.setReleaseDate(new Date(-30481200000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("The Beatles");
      album.setReleaseDate(new Date(-34974000000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Magical Mystery Tour");
      album.setReleaseDate(new Date(-66164400000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Sgt. Pepper's Lonely Hearts Club Band");
      album.setReleaseDate(new Date(-81633600000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Revolver");
      album.setReleaseDate(new Date(-107553600000L));
      em.persist(album);

      album = new Album();
      album.setArtist(beatles);
      album.setFormat(Format.LP);
      album.setName("Rubber Soul");
      album.setReleaseDate(new Date(-128718000000L));
      em.persist(album);

      album = new Album();
      album.setArtist(samNDave);
      album.setFormat(Format.LP);
      album.setName("Hold On, I'm Comin'");
      album.setReleaseDate(new Date(-121114800000L));
      em.persist(album);

      album = new Album();
      album.setArtist(samNDave);
      album.setFormat(Format.LP);
      album.setName("Double Dynamite");
      album.setReleaseDate(new Date(-97354800000L));
      em.persist(album);

      album = new Album();
      album.setArtist(samNDave);
      album.setFormat(Format.LP);
      album.setName("Soul Men");
      album.setReleaseDate(new Date(-71092800000L));
      em.persist(album);

      // Some extra genres to play with
      em.persist(new Genre("Classical"));
      em.persist(new Genre("Country"));
      em.persist(new Genre("Folk"));
      em.persist(new Genre("Funk"));
      em.persist(new Genre("Pop"));

      // store them
      em.flush();
    }
  }
View Full Code Here

     * If there are no Album instances in the database, this method creates and persists a selection of music from the 1960's.
     */
    private void preFillDatabaseIfEmpty() {
        TypedQuery<Album> albums = em.createNamedQuery("allAlbums", Album.class);
        if (albums.getResultList().isEmpty()) {
            Genre rock = new Genre("Rock");
            Genre soul = new Genre("Soul");
            Genre rnb = new Genre("R&B");

            Artist beatles = new Artist();
            beatles.setName("The Beatles");
            beatles.addGenre(rock);

            Artist samNDave = new Artist();
            samNDave.setName("Sam & Dave");
            samNDave.addGenre(rock);
            samNDave.addGenre(soul);
            samNDave.addGenre(rnb);

            Album album = new Album();
            album.setArtist(beatles);
            album.setFormat(Format.LP);
            album.setName("Let It Be");
            album.setReleaseDate(new Date(11012400000L));
            em.persist(album);

            album = new Album();
            album.setArtist(beatles);
            album.setFormat(Format.LP);
            album.setName("Abbey Road");
            album.setReleaseDate(new Date(-8366400000L));
            em.persist(album);

            album = new Album();
            album.setArtist(beatles);
            album.setFormat(Format.LP);
            album.setName("Yellow Submarine");
            album.setReleaseDate(new Date(-30481200000L));
            em.persist(album);

            album = new Album();
            album.setArtist(beatles);
            album.setFormat(Format.LP);
            album.setName("The Beatles");
            album.setReleaseDate(new Date(-34974000000L));
            em.persist(album);

            album = new Album();
            album.setArtist(beatles);
            album.setFormat(Format.LP);
            album.setName("Magical Mystery Tour");
            album.setReleaseDate(new Date(-66164400000L));
            em.persist(album);

            album = new Album();
            album.setArtist(beatles);
            album.setFormat(Format.LP);
            album.setName("Sgt. Pepper's Lonely Hearts Club Band");
            album.setReleaseDate(new Date(-81633600000L));
            em.persist(album);

            album = new Album();
            album.setArtist(beatles);
            album.setFormat(Format.LP);
            album.setName("Revolver");
            album.setReleaseDate(new Date(-107553600000L));
            em.persist(album);

            album = new Album();
            album.setArtist(beatles);
            album.setFormat(Format.LP);
            album.setName("Rubber Soul");
            album.setReleaseDate(new Date(-128718000000L));
            em.persist(album);

            album = new Album();
            album.setArtist(samNDave);
            album.setFormat(Format.LP);
            album.setName("Hold On, I'm Comin'");
            album.setReleaseDate(new Date(-121114800000L));
            em.persist(album);

            album = new Album();
            album.setArtist(samNDave);
            album.setFormat(Format.LP);
            album.setName("Double Dynamite");
            album.setReleaseDate(new Date(-97354800000L));
            em.persist(album);

            album = new Album();
            album.setArtist(samNDave);
            album.setFormat(Format.LP);
            album.setName("Soul Men");
            album.setReleaseDate(new Date(-71092800000L));
            em.persist(album);

            // Some extra genres to play with
            em.persist(new Genre("Classical"));
            em.persist(new Genre("Country"));
            em.persist(new Genre("Folk"));
            em.persist(new Genre("Funk"));
            em.persist(new Genre("Pop"));

            // store them
            em.flush();
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.errai.demo.jpa.client.shared.Genre

Copyright © 2018 www.massapicom. 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.