Skip to content

Commit

Permalink
fieldgen: Update test model
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed Sep 7, 2020
1 parent 24ecd36 commit 522f0f0
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.speedment.jpastreamer.fieldgenerator.test;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "actor", schema = "sakila")
public class Actor {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "actor_id", nullable = false, updatable = false, columnDefinition = "smallint(5)")
private Integer actorId;

@Column(name = "first_name", nullable = false, columnDefinition = "varchar(45)")
private String firstName;

@Column(name = "last_name", nullable = false, columnDefinition = "varchar(45)")
private String lastName;

@ManyToMany(mappedBy = "actors")
private List<Film> films = new ArrayList<>();

public Integer getActorId() {
return actorId;
}

public void setActorId(Integer actorId) {
this.actorId = actorId;
}

public List<Film> getFilms() {
return films;
}

public void setFilms(List<Film> films) {
this.films = films;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

@Override
public String toString() {
return "Actor{" +
"actorId=" + actorId +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
import javax.persistence.*;
import java.sql.Time;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;

@Entity
@Table(name = "film", schema = "sakila")
public class Film
{
public class Film {

// Reproduce #58
private static Map<Class<? extends Film>, List<String>> A = new HashMap<>();

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -47,7 +46,9 @@ public class Film
@Column(name = "long_description", nullable = true)
private String long_description;

/** DATE AND TIME */
/**
* DATE AND TIME
*/
@Column(name = "release_date", nullable = false, columnDefinition = "DATE")
@Temporal(TemporalType.DATE)
private java.util.Date releaseDate;
Expand All @@ -59,18 +60,16 @@ public class Film
@Column(name = "release_time", nullable = false, columnDefinition = "TIME")
private Time releaseTime;

@ManyToOne
@JoinColumn(name = "language_id")
private Language language;

/*@ManyToOne
@JoinColumn(name = "language_id")
private Language language;*/
/*
@ManyToOne
@JoinColumn(name = "original_language_id")
private Language originalLanguage;
*/
@ManyToOne
@JoinColumn(name = "original_language_id")
private Language originalLanguage;

@Column(name = "complex_column")
private Map<Map<List<Set<Double>>,Integer>,Long> complexColumn;
private Map<Map<List<Set<Double>>, Integer>, Long> complexColumn;

@Column(name = "rental_duration", columnDefinition = "smallint(5)")
private Integer rentalDuration;
Expand All @@ -84,6 +83,9 @@ public class Film
@Column(name = "replacement_cost", columnDefinition = "decimal(5,2)")
private Float replacementCost;

@Column(name = "rating", columnDefinition = "enum('G','PG','PG-13','R','NC-17')")
private String rating;

@Column(name = "special_features", columnDefinition = "set('Trailers','Commentaries','Deleted Scenes','Behind the Scenes')")
private Set<String> specialFeatures; // Should be Set<String>

Expand Down Expand Up @@ -123,7 +125,7 @@ public void setReleaseYear(Year releaseYear) {
this.releaseYear = releaseYear;
}*/

/*

public Language getLanguage() {
return language;
}
Expand All @@ -139,7 +141,6 @@ public Language getOriginalLanguage() {
public void setOriginalLanguage(Language originalLanguage) {
this.originalLanguage = originalLanguage;
}
*/

public void setRentalDuration(Integer rentalDuration) {
this.rentalDuration = rentalDuration;
Expand Down Expand Up @@ -233,7 +234,7 @@ public String toString() {
", length=" + length +
", replacementCost=" + replacementCost +
", specialFeatures='" + specialFeatures + '\'' +
// ", lastUpdate=" + lastUpdate +
// ", lastUpdate=" + lastUpdate +
'}';
}

Expand All @@ -260,4 +261,12 @@ public Time getReleaseTime() {
public void setReleaseTime(Time releaseTime) {
this.releaseTime = releaseTime;
}

public String getRating() {
return rating;
}

public void setRating(String rating) {
this.rating = rating;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.speedment.jpastreamer.fieldgenerator.test;


import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;

@Entity
@Table(name = "language", schema = "sakila")
public class Language implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "language_id", nullable = false, updatable = false, columnDefinition = "tinyint(3)")
private Integer languageId;

@Column(name = "name", nullable = false, columnDefinition = "char(20)")
private String name;

@OneToMany(mappedBy = "language")
private Set<Film> films;

@ManyToMany
public Integer getLanguageId() {
return languageId;
}

public void setLanguageId(Integer language_id) {
this.languageId = language_id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Set<Film> getFilms() {
return films;
}

public void setFilms(Set<Film> films) {
this.films = films;
}

@Override
public String toString() {
return "Language{" +
"languageId=" + languageId +
", name='" + name + '\'' +
'}';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public static void main(String[] args) {
spindel.setTitle("Den Disorienterade Spindeln");
spindel.setDescription("Spindeln klättrar upp för sin tråd men allt går åt helvete och spindeln faller ned. Han ger dock ej upp utan försöker ånyo ad infinitum!");
spindel.setLength(110);
/*

Stream.of(olle, spindel)
.filter(Film$.length.between(100, 150))
.filter(Film$.rating.in("G", "PG"))
.sorted(Film$.title)
.forEachOrdered(System.out::println);
*/

}
}

0 comments on commit 522f0f0

Please sign in to comment.