I am trying to save an Enum field in a database, but I had a problem displaying the field in the database. The code I have is as follows:
public enum InvoiceStatus {
PAID,
UNPAID;
}
and I use this enumeration in one of my application classes as follows:
public class Invoice {
Enumerated(EnumType.ORDINAL)
@Column(name="INVOICE_STATUS", nullable = false, unique=false)
private InvoiceStatus invoiceStatus;
}
Finally, I let the user of the application select the account status from the presentation (JSP) using the drop-down menu.
But I'm not sure how to match the value obtained from the drop-down menu in the Invoice Status field
I tried to match the resulting short value as follows, but it will not compile
invoice.setInvoiceStatus(Short.parseShort(request.getParameter("inbStatus")));
can someone tell me how to match the data received from the view to the enumeration field?
Mchan source
share