How to resolve http 500 when I use Jeddic - java

I had write a restful interface in NetbeansIDE8.2 ,and i have debug it with the PostMan App in chorme, and then an exception have experenced I will show the image down here :
the HTTP ERROR 500
and my code is here ,I have return a arryList to browser
#Path("/getStu")
#GET
public List<TfFreshstudent> queryStudentNoDomitory()
{
List<TfFreshstudent> studentList= cq.queryFreshstudentNoDomitory();
if (studentList.isEmpty()) {
return studentList;
}
return null;
}
and I have tried other sub of the automatic create code ,and the error is also happened:
#GET
public List<TfDormitory> getAllTfDormitories() {
log.debug("REST request to get all TfDormitories");
List<TfDormitory> tfDormitories = tfDormitoryFacade.findAll();
return tfDormitories;
}
I have think that it maybe the return type error maybe ArryList can't be show on browser, maybe I must parse it to json type or response

This is the entity which Jeddic was create
package com.freshV3.cart.model;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name = "tf_dormitory")
public class TfDormitory {
#Column(name = "id", table = "tf_dormitory", nullable = false, length = 22)
#Id
private String id;
#Column(name = "buildName", table = "tf_dormitory", length = 50)
#Basic
private String buildName;
#Column(name = "comment", table = "tf_dormitory")
#Basic
private String comment;
#Column(name = "freshStudentId", table = "tf_dormitory", length = 22)
#Basic
private String freshStudentId;
#Column(name = "isDelete", table = "tf_dormitory")
#Basic
private Integer isDelete;
#Column(name = "operator", table = "tf_dormitory", length = 20)
#Basic
private String operator;
#Column(name = "roomCode", table = "tf_dormitory", length = 32)
#Basic
private String roomCode;
#Column(name = "roomId", table = "tf_dormitory")
#Basic
private String roomId;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getBuildName() {
return this.buildName;
}
public void setBuildName(String buildName) {
this.buildName = buildName;
}
public String getComment() {
return this.comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getFreshStudentId() {
return this.freshStudentId;
}
public void setFreshStudentId(String freshStudentId) {
this.freshStudentId = freshStudentId;
}
public Integer getIsDelete() {
return this.isDelete;
}
public void setIsDelete(Integer isDelete) {
this.isDelete = isDelete;
}
public String getOperator() {
return this.operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public String getRoomCode() {
return this.roomCode;
}
public void setRoomCode(String roomCode) {
this.roomCode = roomCode;
}
public String getRoomId() {
return this.roomId;
}
public void setRoomId(String roomId) {
this.roomId = roomId;
}
}

Related

Jakson can not deserialize instance of java.util.ArrayList out of START_OBJECT token

After having sent a POST I receive a 400 error
curl localhost:8888/bills/addbill -H "Content-Type: application/json" -X POST -d '{"number":"111A111", "customer":"Customer Cuustomer Rrrr", "phone":"1 800 5551212", "manager":"Manager Manager Manager", "date":"2012-09-17", "curId":{"id":"1"}, "payments":{["id":"1"]}}'
The response is :
{"timestamp":1503684882518,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Bad Request","path":"/bills/addbill"}
I am getting an exception when I try to deserialize the my json data. How can I deserialize JSON properly?
Bill enntity file is:
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import ru.test.practice.view.PaymentView;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
#JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
#Entity
#Table(name = "Bill")
public class Bill {
#GeneratedValue
#Id
#Column(name = "id")
private Integer id;
#Version
private int version;
#Column(name = "number")
#NotNull(message = "Num should be set")
#Size(min = 6, max = 10)
#Pattern(regexp = "^[^\\W_]+$")
private String number;
#Column(name = "customer")
#NotNull
#Size(max = 256)
#Pattern(regexp = "^[a-zA-Z\\s]*$")
private String customer;
#Column(name = "phone")
#NotNull
#Size(max = 20)
#Pattern(regexp = "(?:(?:\\+?1\\s*(?:[.-]\\s*)?)?(?:(\\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]\u200C\u200B)\\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\\s*(?:[.-]\\s*)?)([2-9]1[02-9]\u200C\u200B|[2-9][02-9]1|[2-9][02-9]{2})\\s*(?:[.-]\\s*)?([0-9]{4})\\s*(?:\\s*(?:#|x\\.?|ext\\.?|extension)\\s*(\\d+)\\s*)?$")
private String phone;
#Column(name = "manager")
#Pattern(regexp = "^[a-zA-Z\\s]*$")
#Size(max = 256)
#NotNull
private String manager;
#Column(name = "date")
#NotNull
private Date date;
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "cur_id")
private Currency curId;
#ManyToMany(targetEntity = ru.test.practice.model.Payment.class)
public List<PaymentView> payments = new ArrayList<>();
public List<PaymentView> getPayments() {
return payments;
}
public void setPayments(List<PaymentView> payments) {
this.payments = payments;
}
public Bill(Integer id, String number, String customer, String phone, String manager, Date date, Currency curId, List<PaymentView> payments) {
this.id = id;
this.number = number;
this.customer = customer;
this.phone = phone;
this.manager = manager;
this.date = date;
this.curId = curId;
this.payments = payments;
}
public Bill() {
this.id = null;
this.number = null;
this.customer = null;
this.phone = null;
this.manager = null;
this.date = null;
this.curId = null;
this.payments = null;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Integer getId() {
return id;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public String getCustomer() {
return customer;
}
public void setCustomer(String customer) {
this.customer = customer;
}
public String getManager() {
return manager;
}
public void setManager(String manager) {
this.manager = manager;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Currency getCurId() {
return curId;
}
public void setCurId(Currency curId) {
this.curId = curId;
}
}
BillView file is
package ru.test.practice.view;
import io.swagger.annotations.ApiModelProperty;
import ru.bellintegrator.practice.model.Currency;
import java.util.Date;
import java.util.List;
public class BillView {
#ApiModelProperty(hidden = true)
public Integer id;
public String customer;
public String phone;
public String manager;
public String number;
public Date date;
public Currency curId;
public List<PaymentView> payments;
//для jackson
public BillView() {
}
public BillView(Integer id, String number, String customer, String phone, String manager, Date date, Currency curId, List<PaymentView> payments) {
this.id = id;
this.number = number;
this.customer = customer;
this.phone = phone;
this.manager = manager;
this.date = date;
this.curId = curId;
this.payments = payments;
}
#Override
public String toString() {
return "{id:" + id +
"billNumber:" + number +
";customer:" + customer +
";phone:" + phone +
";manager:" + manager +
";date:" + date +
";currencyId:" + curId +
";payments:" + payments +
"}";
}
}
Controller in BillController class that handles a POST request
#Override
#ApiOperation(value = "addBill", nickname = "addBill", httpMethod = "POST")
#ApiResponses(value = {
#ApiResponse(code = 200, message = "Success", response = String.class),
#ApiResponse(code = 404, message = "Not Found"),
#ApiResponse(code = 500, message = "Failure")})
#RequestMapping(value = "/addbill", method = {POST})
public void bill(#RequestBody BillView bill) {
billService.add(bill);
}
#Override
#ApiOperation(value = "getBills", nickname = "getBills", httpMethod = "GET")
#RequestMapping(value = "/list", method = {GET})
public List<BillView> bills() {
return billService.bills();
}
Finally my Payments Entity class:
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
#JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
#Entity
#Table(name = "Payments")
public class Payment {
#Id
#GeneratedValue
#Column(name = "id")
private Integer id;
#Version
private Integer version;
#Column(name = "name", nullable = false, length = 256)
private String name;
#Column(name = "price", nullable = false)
private float price;
#ManyToMany(targetEntity = ru.bellintegrator.practice.model.Bill.class, mappedBy = "curId")
private List<Bill> bills = new ArrayList<>();
public List<Bill> getBills() {
return bills;
}
public void setBills(List<Bill> bills) {
this.bills = bills;
}
public Integer getId() {
return id;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
}
you have problem in your json
"payments":{["id":"1"]}
since you are trying to deserialize list of type PaymentView this should be, i suppose PaymentView contains id attribute
"payments":[{"id":"1"}]

how do i set default value in column annotation

I am new in java. i created a entity class. where i wanted a default value for a field. i tried #Column(name = "ProjectStatus", nullable = false,columnDefinition = "varchar(50) default 'start'") annotaions but getting errors
my entity class is
package com.ults.hrms.model;
// default package
// Generated 17 Jan, 2017 12:04:43 PM by Hibernate Tools 3.4.0.CR1
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.ColumnDefault;
#Entity
#Table(name = "t_projectmaster", catalog = "db_hrms")
public class Projectmaster implements java.io.Serializable {
private Integer projectId;
private String projectUserIdtemp;
private String projectUserIdper;
private String projectName;
private String clentName;
private String projectDesc;
private Double projectValue;
private String projectTax;
private Date targetDate;
private Integer accountmanager;
private Integer projectManager;
private byte[] pofile;
private byte[] agreementFile;
/*#Column(name = "ProjectStatus",columnDefinition = "varchar(50) default 'ToStart'")*/
private String projectStatus;
private Boolean actvieStatus;
private Date creationDate;
private Date modifiedDate;
private Integer userId;
private String remarks;
public Projectmaster() {
}
public Projectmaster(String projectStatus) {
this.projectStatus = projectStatus;
}
public Projectmaster(String projectUserIdtemp, String projectUserIdper,
String projectName, String clentName, String projectDesc,
Double projectValue, String projectTax, Date targetDate,
Integer accountmanager, Integer projectManager, byte[] pofile,
byte[] agreementFile, String projectStatus, Boolean actvieStatus,
Date creationDate, Date modifiedDate, Integer userId, String remarks) {
this.projectUserIdtemp = projectUserIdtemp;
this.projectUserIdper = projectUserIdper;
this.projectName = projectName;
this.clentName = clentName;
this.projectDesc = projectDesc;
this.projectValue = projectValue;
this.projectTax = projectTax;
this.targetDate = targetDate;
this.accountmanager = accountmanager;
this.projectManager = projectManager;
this.pofile = pofile;
this.agreementFile = agreementFile;
this.projectStatus = projectStatus;
this.actvieStatus = actvieStatus;
this.creationDate = creationDate;
this.modifiedDate = modifiedDate;
this.userId = userId;
this.remarks = remarks;
}
#Id
#GeneratedValue(strategy = IDENTITY)
#Column(name = "ProjectID", unique = true, nullable = false)
public Integer getProjectId() {
return this.projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
#Column(name = "ProjectUserIDTemp", length = 50)
public String getProjectUserIdtemp() {
return this.projectUserIdtemp;
}
public void setProjectUserIdtemp(String projectUserIdtemp) {
this.projectUserIdtemp = projectUserIdtemp;
}
#Column(name = "ProjectUserIDPer", length = 50)
public String getProjectUserIdper() {
return this.projectUserIdper;
}
public void setProjectUserIdper(String projectUserIdper) {
this.projectUserIdper = projectUserIdper;
}
#Column(name = "ProjectName")
public String getProjectName() {
return this.projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
#Column(name = "ClentName", length = 100)
public String getClentName() {
return this.clentName;
}
public void setClentName(String clentName) {
this.clentName = clentName;
}
#Column(name = "ProjectDesc", length = 65535)
public String getProjectDesc() {
return this.projectDesc;
}
public void setProjectDesc(String projectDesc) {
this.projectDesc = projectDesc;
}
#Column(name = "ProjectValue", precision = 22, scale = 0)
public Double getProjectValue() {
return this.projectValue;
}
public void setProjectValue(Double projectValue) {
this.projectValue = projectValue;
}
#Column(name = "ProjectTax", length = 50)
public String getProjectTax() {
return this.projectTax;
}
public void setProjectTax(String projectTax) {
this.projectTax = projectTax;
}
#Temporal(TemporalType.DATE)
#Column(name = "TargetDate", length = 10)
public Date getTargetDate() {
return this.targetDate;
}
public void setTargetDate(Date targetDate) {
this.targetDate = targetDate;
}
#Column(name = "Accountmanager")
public Integer getAccountmanager() {
return this.accountmanager;
}
public void setAccountmanager(Integer accountmanager) {
this.accountmanager = accountmanager;
}
#Column(name = "ProjectManager")
public Integer getProjectManager() {
return this.projectManager;
}
public void setProjectManager(Integer projectManager) {
this.projectManager = projectManager;
}
#Column(name = "POFile")
public byte[] getPofile() {
return this.pofile;
}
public void setPofile(byte[] pofile) {
this.pofile = pofile;
}
#Column(name = "AgreementFile")
public byte[] getAgreementFile() {
return this.agreementFile;
}
public void setAgreementFile(byte[] agreementFile) {
this.agreementFile = agreementFile;
}
#Column(name = "ProjectStatus", nullable = false,columnDefinition = "varchar(50) default 'start'")
public String getProjectStatus() {
return this.projectStatus;
}
public void setProjectStatus(String projectStatus) {
this.projectStatus = projectStatus;
}
#Column(name = "ActvieStatus")
public Boolean getActvieStatus() {
return this.actvieStatus;
}
public void setActvieStatus(Boolean actvieStatus) {
this.actvieStatus = actvieStatus;
}
#Temporal(TemporalType.TIMESTAMP)
#Column(name = "CreationDate",columnDefinition = "DATE DEFAULT CURRENT_DATE", length = 19)
public Date getCreationDate() {
return this.creationDate;
}
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
#Temporal(TemporalType.TIMESTAMP)
#Column(name = "ModifiedDate", length = 19)
public Date getModifiedDate() {
return this.modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
this.modifiedDate = modifiedDate;
}
#Column(name = "UserID")
public Integer getUserId() {
return this.userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
#Column(name = "Remarks", length = 65535)
public String getRemarks() {
return this.remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
}
This will work for you,
Initialise the attribute while creating object only.
private String projectStatus = "start";

I'm not able to select particular column from a JPQL?

here is my query where I'm trying to get id and userNotes from Job Class.
#Query("SELECT j.id, j.userNotes FROM Job j WHERE j.bookingTime BETWEEN :stDate AND :edDate")
List<Job> getDriverCalendar(#Param("stDate") Timestamp stDate, #Param("edDate") Timestamp edDate);
Job.java
package com.housecar.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
#Entity
#EntityListeners(AuditingEntityListener.class)
#Table(name = "hc_job")
public class Job{
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#Column(name = "ride_time")
private Timestamp rideTime;
#Column(name = "booking_time")
private Timestamp bookingTime;
#Column(name = "guest_id")
private Long guestId;
#Column(name = "booked_user_id")
private Long bookedUserId;
#Column(name = "car_id")
private Long carId;
#Column(name = "pickup_location")
private String pickupLocation;
#Column(name = "drop_location")
private String dropLocation;
#Column(name = "trip_type")
private Character tripType;
#Column(name = "is_private_job")
private Boolean isPrivateJob;
#Column(name = "estimated_fare")
private BigDecimal estimatedFare;
#Column(name = "actual_fare")
private BigDecimal actualFare;
#Column(name = "tip")
private BigDecimal tip;
#Column(name = "payment_status")
private Character paymentStatus;
#Column(name = "user_notes")
private String userNotes;
#Column(name = "cancellation_notes")
private String cancellationNotes;
#Column(name = "status")
private Character status;
#OneToOne
#JoinColumn(name = "id", referencedColumnName = "id", insertable = false, updatable = false)
private JobDriverRating jobDriverRating;
#OneToOne
#JoinColumn(name = "id", referencedColumnName = "id", insertable = false, updatable = false)
private JobCostSplit jobCostSplit;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getGuestId() {
return guestId;
}
public void setGuestId(Long guestId) {
this.guestId = guestId;
}
public Long getBookedUserId() {
return bookedUserId;
}
public void setBookedUserId(Long bookedUserId) {
this.bookedUserId = bookedUserId;
}
public Long getCarId() {
return carId;
}
public void setCarId(Long carId) {
this.carId = carId;
}
public String getPickupLocation() {
return pickupLocation;
}
public void setPickupLocation(String pickupLocation) {
this.pickupLocation = pickupLocation;
}
public String getDropLocation() {
return dropLocation;
}
public void setDropLocation(String dropLocation) {
this.dropLocation = dropLocation;
}
public Character getTripType() {
return tripType;
}
public void setTripType(Character tripType) {
this.tripType = tripType;
}
public Boolean getIsPrivateJob() {
return isPrivateJob;
}
public void setIsPrivateJob(Boolean isPrivateJob) {
this.isPrivateJob = isPrivateJob;
}
public BigDecimal getEstimatedFare() {
return estimatedFare;
}
public void setEstimatedFare(BigDecimal estimatedFare) {
this.estimatedFare = estimatedFare;
}
public BigDecimal getActualFare() {
return actualFare;
}
public void setActualFare(BigDecimal actualFare) {
this.actualFare = actualFare;
}
public BigDecimal getTip() {
return tip;
}
public void setTip(BigDecimal tip) {
this.tip = tip;
}
public Character getPaymentStatus() {
return paymentStatus;
}
public void setPaymentStatus(Character paymentStatus) {
this.paymentStatus = paymentStatus;
}
public String getUserNotes() {
return userNotes;
}
public void setUserNotes(String userNotes) {
this.userNotes = userNotes;
}
public String getCancellationNotes() {
return cancellationNotes;
}
public void setCancellationNotes(String cancellationNotes) {
this.cancellationNotes = cancellationNotes;
}
public Character getStatus() {
return status;
}
public void setStatus(Character status) {
this.status = status;
}
public JobDriverRating getJobDriverRating() {
return jobDriverRating;
}
public void setJobDriverRating(JobDriverRating jobDriverRating) {
this.jobDriverRating = jobDriverRating;
}
public Timestamp getRideTime() {
return rideTime;
}
public void setRideTime(Timestamp rideTime) {
this.rideTime = rideTime;
}
public Timestamp getBookingTime() {
return bookingTime;
}
public void setBookingTime(Timestamp bookingTime) {
this.bookingTime = bookingTime;
}
public JobCostSplit getJobCostSplit() {
return jobCostSplit;
}
public void setJobCostSplit(JobCostSplit jobCostSplit) {
this.jobCostSplit = jobCostSplit;
}
}
#Query("SELECT j.id, j.userNotes FROM Job j WHERE j.bookingTime BETWEEN :stDate AND :edDate") this query returned [ ].
#Query("SELECT j FROM Job j WHERE j.bookingTime BETWEEN :stDate AND :edDate") this query returned the complete Job object.
Your query doesn't select a Job. It selects two fields. Such a JPQL query returns a List<Object[]>, where each array of the list has two elements.
The return type of the method should thus be changed to List<Object[]>.
In the above query use the alias name for each value fetched
You will get the result as the list of hashmap so change the return type from List<Job> to List<Map> as shown below,
#Query("SELECT j.id as id , j.userNotes as userNotes FROM Job j WHERE j.bookingTime BETWEEN :stDate AND :edDate")
List<Map> getDriverCalendar(#Param("stDate") Timestamp stDate, #Param("edDate") Timestamp edDate);

count rows in table using jpa

i'm trying to develop a function that count number of rows with specific arguments: for example i want to count the number of dossier which the client is 'client a' i want to get it in a table the first case contain the name of client and the second contanint the number of dossier
for example
client a |5
client b |12
....
right now i just wrote a function that returns the number of all rows
public Object countrow(){
Query query=em.createQuery("SELECT COUNT(d) FROM Dossier d");
Object resultat= query.getSingleResult();
System.out.println(resultat);
return resultat;
}
here's my entity named dossier :
package model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
#Entity
#NamedQueries({ #NamedQuery(name = "Dossier.findAll", query = "select o from Dossier o") })
public class Dossier implements Serializable {
#Column(name = "CAT_PROB", length = 4000)
private String catProb;
#Column(length = 4000)
private String client;
#Column(length = 4000)
private String contact;
#Temporal(TemporalType.DATE)
#Column(name = "DATE_APPEL")
private Date dateAppel;
#Temporal(TemporalType.DATE)
#Column(name = "DATE_CREATION")
private Date dateCreation;
#Temporal(TemporalType.DATE)
#Column(name = "DATE_FERMERTURE")
private Date dateFermerture;
#Column(name = "DEP_ID", length = 4000)
private String depId;
#Column(name = "DESCRI_PROB", length = 4000)
private String descriProb;
#Column(name = "DUREE_TRAITEMENT")
private Long dureeTraitement;
#Column(length = 4000)
private String etat;
#Column(name = "FINAL", length = 4000)
private String final_;
#Column(name = "HEURE_APPEL", length = 20)
private String heureAppel;
#Column(name = "HEURE_FERMETURE", length = 20)
private String heureFermeture;
#Id
#Column(name = "ID_DOSSIER", nullable = false, length = 4000)
private String idDossier;
#Column(name = "ING_AFF", length = 4000)
private String ingAff;
#Column(length = 4000)
private String motiftemp;
#Column(name = "OUVERT_PAR", length = 4000)
private String ouvertPar;
#Column(name = "TEL_CONTACT")
private BigDecimal telContact;
#Column(name = "TYPE_DOSSIER", length = 4000)
private String typeDossier;
public Dossier() {
}
public Dossier(String catProb, String client, String contact, Date dateAppel, Date dateCreation,
Date dateFermerture, String depId, String descriProb, Long dureeTraitement, String etat,
String final_, String heureAppel, String heureFermeture, String idDossier, String ingAff,
String motiftemp, String ouvertPar, BigDecimal telContact, String typeDossier) {
this.catProb = catProb;
this.client = client;
this.contact = contact;
this.dateAppel = dateAppel;
this.dateCreation = dateCreation;
this.dateFermerture = dateFermerture;
this.depId = depId;
this.descriProb = descriProb;
this.dureeTraitement = dureeTraitement;
this.etat = etat;
this.final_ = final_;
this.heureAppel = heureAppel;
this.heureFermeture = heureFermeture;
this.idDossier = idDossier;
this.ingAff = ingAff;
this.motiftemp = motiftemp;
this.ouvertPar = ouvertPar;
this.telContact = telContact;
this.typeDossier = typeDossier;
}
public String getCatProb() {
return catProb;
}
public void setCatProb(String catProb) {
this.catProb = catProb;
}
public String getClient() {
return client;
}
public void setClient(String client) {
this.client = client;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
public Date getDateAppel() {
return dateAppel;
}
public void setDateAppel(Date dateAppel) {
this.dateAppel = dateAppel;
}
public Date getDateCreation() {
return dateCreation;
}
public void setDateCreation(Date dateCreation) {
this.dateCreation = dateCreation;
}
public Date getDateFermerture() {
return dateFermerture;
}
public void setDateFermerture(Date dateFermerture) {
this.dateFermerture = dateFermerture;
}
public String getDepId() {
return depId;
}
public void setDepId(String depId) {
this.depId = depId;
}
public String getDescriProb() {
return descriProb;
}
public void setDescriProb(String descriProb) {
this.descriProb = descriProb;
}
public Long getDureeTraitement() {
return dureeTraitement;
}
public void setDureeTraitement(Long dureeTraitement) {
this.dureeTraitement = dureeTraitement;
}
public String getEtat() {
return etat;
}
public void setEtat(String etat) {
this.etat = etat;
}
public String getFinal_() {
return final_;
}
public void setFinal_(String final_) {
this.final_ = final_;
}
public String getHeureAppel() {
return heureAppel;
}
public void setHeureAppel(String heureAppel) {
this.heureAppel = heureAppel;
}
public String getHeureFermeture() {
return heureFermeture;
}
public void setHeureFermeture(String heureFermeture) {
this.heureFermeture = heureFermeture;
}
public String getIdDossier() {
return idDossier;
}
public void setIdDossier(String idDossier) {
this.idDossier = idDossier;
}
public String getIngAff() {
return ingAff;
}
public void setIngAff(String ingAff) {
this.ingAff = ingAff;
}
public String getMotiftemp() {
return motiftemp;
}
public void setMotiftemp(String motiftemp) {
this.motiftemp = motiftemp;
}
public String getOuvertPar() {
return ouvertPar;
}
public void setOuvertPar(String ouvertPar) {
this.ouvertPar = ouvertPar;
}
public BigDecimal getTelContact() {
return telContact;
}
public void setTelContact(BigDecimal telContact) {
this.telContact = telContact;
}
public String getTypeDossier() {
return typeDossier;
}
public void setTypeDossier(String typeDossier) {
this.typeDossier = typeDossier;
}
}

How to add series of keys on an Entity? Openjpa

I have this entity named product. Is there a way to add a series of multiple keys? Like A key for Serial Number, a key for Serial Number and Model, a key for Model etc. How can you do this? Thank you very much.
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package lotmovement.business.entity;
import java.io.Serializable;
import java.sql.Timestamp;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Version;
/**
*
* #author god-gavedmework
*/
#Entity
public class Product implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long product_Id;
#Column(name = "SERIAL_NUMBER", nullable = false,length = 30)
private String serial_Number;
#Column(name = "DATE_ASSEMBLED", nullable = false,length = 10)
private String date_Assembled;
#Column(name = "TIME_ASSEMBLED", nullable = false,length = 20)
private String time_Assembled;
#Column(name = "MODEL", nullable = false,length = 20)
private String model;
#Column(name = "BATCH_ID", nullable = false,length = 6)
private int batch_Id;
#Column(name = "PROCESS_CODE", nullable = false,length = 3)
private int process_Code;
#Column(name = "DC_POWER_PCB_SERIAL", nullable = false,length = 20)
private String dc_Power_PCB_Serial;
#Column(name = "CONTROL_PWER_PCB_SERIAL", nullable = false,length = 20)
private String control_Power_PCB_Serial;
#Column(name = "MAINS_POWER_PCB_SERIAL", nullable = false,length = 20)
private String mains_Power_PCB_Serial;
#Column(name = "BLOWER_SERIAL", nullable = false,length = 20)
private String blower_Serial;
#Column(name = "HEATERPLATE_SERIAL", nullable = false,length = 20)
private String heaterPlate_Serial;
#Column(name = "LAST_PROCESS", nullable = false,length = 3)
private String last_Process;
#Column(name = "LAST_DATE", nullable = false,length = 20)
private String last_Date;
#Version
#Column(name = "LAST_UPDATED_TIME")
private java.sql.Timestamp updatedTime;
public Timestamp getUpdatedTime() {
return updatedTime;
}
public void setUpdatedTime(Timestamp updatedTime) {
this.updatedTime = updatedTime;
}
public Long getProduct_Id() {
return product_Id;
}
public void setProduct_Id(Long product_Id) {
this.product_Id = product_Id;
}
public String getSerial_Number() {
return serial_Number;
}
public void setSerial_Number(String serial_Number) {
this.serial_Number = serial_Number;
}
public String getDate_Assembled() {
return date_Assembled;
}
public void setDate_Assembled(String date_Assembled) {
this.date_Assembled = date_Assembled;
}
public String getTime_Assembled() {
return time_Assembled;
}
public void setTime_Assembled(String time_Assembled) {
this.time_Assembled = time_Assembled;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getBatch_Id() {
return batch_Id;
}
public void setBatch_Id(int batch_Id) {
this.batch_Id = batch_Id;
}
public int getProcess_Code() {
return process_Code;
}
public void setProcess_Code(int process_Code) {
this.process_Code = process_Code;
}
public String getDc_Power_PCB_Serial() {
return dc_Power_PCB_Serial;
}
public void setDc_Power_PCB_Serial(String dc_Power_PCB_Serial) {
this.dc_Power_PCB_Serial = dc_Power_PCB_Serial;
}
public String getControl_Power_PCB_Serial() {
return control_Power_PCB_Serial;
}
public void setControl_Power_PCB_Serial(String control_Power_PCB_Serial) {
this.control_Power_PCB_Serial = control_Power_PCB_Serial;
}
public String getMains_Power_PCB_Serial() {
return mains_Power_PCB_Serial;
}
public void setMains_Power_PCB_Serial(String mains_Power_PCB_Serial) {
this.mains_Power_PCB_Serial = mains_Power_PCB_Serial;
}
public String getBlower_Serial() {
return blower_Serial;
}
public void setBlower_Serial(String blower_Serial) {
this.blower_Serial = blower_Serial;
}
public String getHeaterPlate_Serial() {
return heaterPlate_Serial;
}
public void setHeaterPlate_Serial(String heaterPlate_Serial) {
this.heaterPlate_Serial = heaterPlate_Serial;
}
public String getLast_Process() {
return last_Process;
}
public void setLast_Process(String last_Process) {
this.last_Process = last_Process;
}
public String getLast_Date() {
return last_Date;
}
public void setLast_Date(String last_Date) {
this.last_Date = last_Date;
}
}
I believe what you are looking for is fundamentally incorrect. A Key should be a unique identifier for an instance of entity. In your example, you want to have a key for "Model", it simply doesn't sounds right.
If you mean something else for "Key", please clarify and we may further discuss on it.

Categories

Resources