Commit 2bdd99c7 authored by Jakub Balga's avatar Jakub Balga
Browse files

Implemented grape, harvest, wineType entity classes and their DAO

parent bac22f20
package cz.muni.fi.pa165.winery.persistence.dao.wine;
import cz.muni.fi.pa165.winery.persistence.dao.DaoBase;
import cz.muni.fi.pa165.winery.persistence.entities.Grape;
/**
* @author Jakub Balga
*/
public interface GrapeDao extends DaoBase<Grape> {
}
package cz.muni.fi.pa165.winery.persistence.dao.wine;
import cz.muni.fi.pa165.winery.persistence.dao.DaoBaseImpl;
import cz.muni.fi.pa165.winery.persistence.entities.Grape;
/**
* @author Jakub Balga
*/
public class GrapeDaoImpl extends DaoBaseImpl<Grape> implements GrapeDao {
public GrapeDaoImpl(){
super(Grape.class);
}
}
package cz.muni.fi.pa165.winery.persistence.dao.wine;
import cz.muni.fi.pa165.winery.persistence.dao.DaoBase;
import cz.muni.fi.pa165.winery.persistence.entities.Harvest;
/**
* @author Jakub Balga
*/
public interface HarvestDao extends DaoBase<Harvest> {
}
package cz.muni.fi.pa165.winery.persistence.dao.wine;
import cz.muni.fi.pa165.winery.persistence.dao.DaoBaseImpl;
import cz.muni.fi.pa165.winery.persistence.entities.Harvest;
/**
* @author Jakub Balga
*/
public class HarvestDaoImpl extends DaoBaseImpl<Harvest> implements HarvestDao {
public HarvestDaoImpl(){
super(Harvest.class);
}
}
package cz.muni.fi.pa165.winery.persistence.dao.wine;
import cz.muni.fi.pa165.winery.persistence.dao.DaoBase;
import cz.muni.fi.pa165.winery.persistence.entities.WineType;
/**
* @author Jakub Balga
*/
public interface WineTypeDao extends DaoBase<WineType> {
}
package cz.muni.fi.pa165.winery.persistence.dao.wine;
import cz.muni.fi.pa165.winery.persistence.dao.DaoBaseImpl;
import cz.muni.fi.pa165.winery.persistence.entities.WineType;
/**
* @author Jakub Balga
*/
public class WineTypeDaoImpl extends DaoBaseImpl<WineType> implements WineTypeDao {
public WineTypeDaoImpl(){
super(WineType.class);
}
}
package cz.muni.fi.pa165.winery.persistence.entities;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;
/**
* @author Jakub Balga
*/
@Getter
@Setter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "GrapeVariety")
public class Grape extends EntityBase {
@Column(nullable = false)
@NotBlank
private String name;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "grapeVariety")
@Fetch(FetchMode.SELECT)
private List<Harvest> harvests = new ArrayList<>();
@OneToMany(fetch = FetchType.EAGER, mappedBy = "grapeVariety")
@Fetch(FetchMode.SELECT)
private List<WineType> wineTypes = new ArrayList<>();
//@OneToMany(fetch = FetchType.EAGER, mappedBy = "grapeVariety")
//@Fetch(FetchMode.SELECT)
//private List<WineBottle> wineBottles = new ArrayList<>();
}
package cz.muni.fi.pa165.winery.persistence.entities;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
/**
* @author Jakub Balga
*/
@Getter
@Setter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "Harvest")
public class Harvest extends EntityBase {
@Column(nullable = false)
@NotNull
@Positive
private Integer year;
@Column(nullable = false)
@NotNull
@PositiveOrZero
private Short grade;
@Column(nullable = false)
@NotNull
@PositiveOrZero
private BigDecimal yieldKilograms;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
private Grape grapeVariety;
}
package cz.muni.fi.pa165.winery.persistence.entities;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;
/**
* @author Jakub Balga
*/
@Getter
@Setter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "WineType")
public class WineType extends EntityBase {
@NotBlank
private String name;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
private Grape grapeVariety;
//@OneToMany(fetch = FetchType.EAGER, mappedBy = "wineType")
//@Fetch(FetchMode.SELECT)
//private List<WineBottle> wineBottles = new ArrayList<>();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment