parent
4f0ccdd3a2
commit
5eb3df20dc
5 changed files with 4 additions and 103 deletions
@ -1,64 +0,0 @@ |
|||||||
package com.codenotfound.primefaces; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
import javax.persistence.Entity; |
|
||||||
import javax.persistence.GeneratedValue; |
|
||||||
import javax.persistence.GenerationType; |
|
||||||
import javax.persistence.Id; |
|
||||||
|
|
||||||
@Entity(name = "Car") |
|
||||||
public class Car implements Serializable { |
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L; |
|
||||||
|
|
||||||
@Id |
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY) |
|
||||||
private Long id; |
|
||||||
|
|
||||||
private String brand; |
|
||||||
|
|
||||||
private int year; |
|
||||||
|
|
||||||
private String color; |
|
||||||
|
|
||||||
public Car() {} |
|
||||||
|
|
||||||
public Car(Long id, String brand, int year, String color) { |
|
||||||
this.id = id; |
|
||||||
this.brand = brand; |
|
||||||
this.year = year; |
|
||||||
this.color = color; |
|
||||||
} |
|
||||||
|
|
||||||
public Long getId() { |
|
||||||
return id; |
|
||||||
} |
|
||||||
|
|
||||||
public void setId(Long id) { |
|
||||||
this.id = id; |
|
||||||
} |
|
||||||
|
|
||||||
public String getBrand() { |
|
||||||
return brand; |
|
||||||
} |
|
||||||
|
|
||||||
public void setBrand(String brand) { |
|
||||||
this.brand = brand; |
|
||||||
} |
|
||||||
|
|
||||||
public int getYear() { |
|
||||||
return year; |
|
||||||
} |
|
||||||
|
|
||||||
public void setYear(int year) { |
|
||||||
this.year = year; |
|
||||||
} |
|
||||||
|
|
||||||
public String getColor() { |
|
||||||
return color; |
|
||||||
} |
|
||||||
|
|
||||||
public void setColor(String color) { |
|
||||||
this.color = color; |
|
||||||
} |
|
||||||
} |
|
@ -1,8 +0,0 @@ |
|||||||
package com.codenotfound.primefaces; |
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository; |
|
||||||
import org.springframework.stereotype.Repository; |
|
||||||
|
|
||||||
@Repository |
|
||||||
public interface CarRepository extends JpaRepository<Car, Long> { |
|
||||||
} |
|
@ -1,29 +0,0 @@ |
|||||||
package com.codenotfound.primefaces; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
import java.util.List; |
|
||||||
import javax.annotation.PostConstruct; |
|
||||||
import javax.faces.view.ViewScoped; |
|
||||||
import javax.inject.Inject; |
|
||||||
import javax.inject.Named; |
|
||||||
|
|
||||||
@Named |
|
||||||
@ViewScoped |
|
||||||
public class CarsView implements Serializable { |
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L; |
|
||||||
|
|
||||||
@Inject |
|
||||||
private CarRepository carRepository; |
|
||||||
|
|
||||||
private List<Car> cars; |
|
||||||
|
|
||||||
@PostConstruct |
|
||||||
public void init() { |
|
||||||
cars = carRepository.findAll(); |
|
||||||
} |
|
||||||
|
|
||||||
public List<Car> getCars() { |
|
||||||
return cars; |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue