/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.sanu.siri.entity;
import javax.persistence.*;
import java.sql.Blob;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author Sanu AK
*/
@Entity
@Table(name = "Parts")
public class Parts implements SuperEntity {
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "map")
@TableGenerator(name = "map", table = "Id_Gen", pkColumnName = "Tables_Names", valueColumnName = "Gen_keys", pkColumnValue = "PartsDTO", initialValue = 1, allocationSize = 1)
private int id;
private String partName;
private String partNumber;
private String barCode;
private String brand;
private String partType;
private String country;
private String vehicleModel;
private String packSize;
private String location;
private String rackNo;
private String roq;
private String rql;
@Column(name = "imageUrl1")
private String imageUrl1;
@Column(name = "imageUrl2")
private String imageUrl2;
@Column(name = "imageUrl3")
private String imageUrl3;
@Column(name = "imageUrl4")
private String imageUrl4;
private Blob image;
private Blob image1;
private Blob image2;
private Blob image3;
private String warranty;
private Date adedDate;
@Enumerated(value = EnumType.STRING)
private Catogary catogary;
@ManyToMany(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
@JoinTable(name = "Parts_FuelType",
joinColumns = {@JoinColumn(name = "part_ID", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "fuel_Type", referencedColumnName = "id")})
private List<FuelType> fuelTypes = new ArrayList<>();
@OneToMany(mappedBy = "parts", cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
private List<OrderDetails> orderDetail = new ArrayList<>();
@OneToMany(mappedBy = "parts", cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
@OrderBy("date DESC")
private List<Bulk> bulks = new ArrayList<>();
public Parts() {
}
public Parts(String partName, String partNumber, String barCode, String brand, String partType, String country, String vehicleModel, String packSize, String location, String rackNo, String roq, String rql, Blob image, Blob image1, Blob image2, Blob image3, String warranty, Date adedDate, Catogary catogary, List<FuelType> fuelTypes, List<OrderDetails> orderDetail, List<Bulk> bulks) {
this.partName = partName;
this.partNumber = partNumber;
this.barCode = barCode;
this.brand = brand;
this.partType = partType;
this.country = country;
this.vehicleModel = vehicleModel;
this.packSize = packSize;
this.location = location;
this.rackNo = rackNo;
this.roq = roq;
this.rql = rql;
this.image = image;
this.image1 = image1;
this.image2 = image2;
this.image3 = image3;
this.warranty = warranty;
this.adedDate = adedDate;
this.catogary = catogary;
this.fuelTypes = fuelTypes;
this.orderDetail = orderDetail;
this.bulks = bulks;
}
public Parts(int id, String partName, String partNumber, String barCode, String brand, String partType, String country, String vehicleModel, String packSize, String location, String rackNo, String roq, String rql, String imageUrl1, String imageUrl2, String imageUrl3, String imageUrl4, Blob image, Blob image1, Blob image2, Blob image3, String warranty, Date adedDate, Catogary catogary, List<FuelType> fuelTypes, List<OrderDetails> orderDetail, List<Bulk> bulks) {
this.setId(id);
this.partName = partName;
this.partNumber = partNumber;
this.barCode = barCode;
this.brand = brand;
this.partType = partType;
this.country = country;
this.vehicleModel = vehicleModel;
this.packSize = packSize;
this.location = location;
this.rackNo = rackNo;
this.roq = roq;
this.rql = rql;
this.imageUrl1 = imageUrl1;
this.imageUrl2 = imageUrl2;
this.imageUrl3 = imageUrl3;
this.imageUrl4 = imageUrl4;
this.image = image;
this.image1 = image1;
this.image2 = image2;
this.image3 = image3;
this.warranty = warranty;
this.adedDate = adedDate;
this.catogary = catogary;
this.fuelTypes = fuelTypes;
this.orderDetail = orderDetail;
this.bulks = bulks;
}
public String getImageUrl1() {
return imageUrl1;
}
public void setImageUrl1(String imageUrl1) {
this.imageUrl1 = imageUrl1;
}
public String getImageUrl2() {
return imageUrl2;
}
public void setImageUrl2(String imageUrl2) {
this.imageUrl2 = imageUrl2;
}
public String getImageUrl3() {
return imageUrl3;
}
public void setImageUrl3(String imageUrl3) {
this.imageUrl3 = imageUrl3;
}
public String getImageUrl4() {
return imageUrl4;
}
public void setImageUrl4(String imageUrl4) {
this.imageUrl4 = imageUrl4;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPartName() {
return partName;
}
public void setPartName(String partName) {
this.partName = partName;
}
public String getPartNumber() {
return partNumber;
}
public void setPartNumber(String partNumber) {
this.partNumber = partNumber;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getPartType() {
return partType;
}
public void setPartType(String partType) {
this.partType = partType;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getVehicleModel() {
return vehicleModel;
}
public void setVehicleModel(String vehicleModel) {
this.vehicleModel = vehicleModel;
}
public String getPackSize() {
return packSize;
}
public void setPackSize(String packSize) {
this.packSize = packSize;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getRackNo() {
return rackNo;
}
public void setRackNo(String rackNo) {
this.rackNo = rackNo;
}
public String getRoq() {
return roq;
}
public void setRoq(String roq) {
this.roq = roq;
}
public String getRql() {
return rql;
}
public void setRql(String rql) {
this.rql = rql;
}
public Blob getImage() {
return image;
}
public void setImage(Blob image) {
this.image = image;
}
public Blob getImage1() {
return image1;
}
public void setImage1(Blob image1) {
this.image1 = image1;
}
public Blob getImage2() {
return image2;
}
public void setImage2(Blob image2) {
this.image2 = image2;
}
public Blob getImage3() {
return image3;
}
public void setImage3(Blob image3) {
this.image3 = image3;
}
public String getWarranty() {
return warranty;
}
public void setWarranty(String warranty) {
this.warranty = warranty;
}
public Date getAdedDate() {
return adedDate;
}
public void setAdedDate(Date adedDate) {
this.adedDate = adedDate;
}
public Catogary getCatogary() {
return catogary;
}
public void setCatogary(Catogary catogary) {
this.catogary = catogary;
}
public List<FuelType> getFuelTypes() {
return fuelTypes;
}
public void setFuelTypes(List<FuelType> fuelTypes) {
this.fuelTypes = fuelTypes;
}
public List<OrderDetails> getOrderDetail() {
return orderDetail;
}
public void setOrderDetail(List<OrderDetails> orderDetail) {
this.orderDetail = orderDetail;
}
public List<Bulk> getBulks() {
return bulks;
}
public void setBulks(List<Bulk> bulks) {
this.bulks = bulks;
}
@Override
public String toString() {
return "Parts{" +
"id=" + id +
", partName='" + partName + '\'' +
", partNumber='" + partNumber + '\'' +
", barCode='" + barCode + '\'' +
", brand='" + brand + '\'' +
", partType='" + partType + '\'' +
", country='" + country + '\'' +
", vehicleModel='" + vehicleModel + '\'' +
", packSize='" + packSize + '\'' +
", location='" + location + '\'' +
", rackNo='" + rackNo + '\'' +
", roq='" + roq + '\'' +
", rql='" + rql + '\'' +
", image=" + image +
", image1=" + image1 +
", image2=" + image2 +
", image3=" + image3 +
", warranty='" + warranty + '\'' +
", adedDate=" + adedDate +
", catogary=" + catogary +
", fuelTypes=" + fuelTypes +
", orderDetail=" + orderDetail +
", bulks=" + bulks +
'}';
}
}
我对此行有疑问。当我们从零件中调用此BulkList时,有什么方法可以限制那些BulkList。
@OrderBy("date DESC")
private List<Bulk> bulks = new ArrayList<>();
我的意思是这样
这是我的仓库
public interface PartsRepo extends CrudRepository<Parts, Integer> {
Parts findPartsByBarCode(String barCode) throws Exception;
List<Parts> findPartsByPartNameContaining(String partName) throws Exception;
List<Parts> findPartsByPartNumberContaining(String partNumber) throws Exception;
Parts findPartsByPartNumber(String partNumber) throws Exception;
}
这是我的控制器
@GetMapping(value = "/search")
public void searchParts(HttpServletRequest req) {
try {
return
Parts
p=partsService.searchParts(Integer.parseInt(req.getParameter("id")));
List<Bulk> bulkList=p.getBulks();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
我想限制实体的bulkList结果。是否有任何方法可以做到这一点??
List<Bulk> bulkList=p.getBulks();
在
列表上方 @OrderBy("date DESC")
private List<Bulk> bulks = new ArrayList<>();
评论
我对此行有疑问,当我们从零件中调用此BulkList时,是否有任何方法可以限制那些BulkList。
我想限制实体的bulkList结果。有什么办法吗?
答案 0 :(得分:0)
@OneToMany(mappedBy = "bulk", cascade=CascadeType.PERSIST, fetch=LAZY)
@BatchSize(size=5)
private List<Bulk> bulks = new ArrayList<>();
您可以这样做