My problem is the following: so I have a database that has some customers stored in it. For every customer I added a picture like this:
INSERT INTO ITSO.CUSTOMER (TITLE,FIRST_NAME,LAST_NAME,SSN,IMAGE) VALUES ('Mr','Henry','Cui','111-11-1111', LOAD_FILE('D:/Workspace8/Images/11.jpg'));
How can I retrieve these pictures in an Enterprise java bean? ( I have to mention I am using JPAs). Are the queries a solution?
@NamedQuery(name="getImageForCustomer", query="select image from Customer c where c.ssn=?1")
Do I need to store my picture in a different way? In the EJB I have this method getCustomer(). Can I add another argument, something like Byte[] image??
public Customer getCustomer(String ssn) throws ITSOBankException {
System.out.println("getCustomer: " + ssn);
try {
return entityMgr.find(Customer.class, ssn);
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
throw new ITSOBankException(ssn);
}
My plan is to display the image in a JSP afterwards, using a servlet and an EJB injection.
I would be so grateful if someone can help me!!!
(It's for learning purpose)