title says everything. Right now my code adds key values to the database, i think the problem is in my model class or servlet class. Id like to save Map<String, String>
value into the String customerType
field
Model :
@Id
@SequenceGenerator(name = "my_seq", sequenceName = "seq1", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "my_seq")
public long id;
private String firstName;
private String customerType;
@ElementCollection
@Column(name="customerType")
public Map<String, String> customerTypes;
I put values into map, using servlet class, which looks like this :
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
showForm(request, response);
}
private void showForm(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("","");
map.put("customerType.private", "Private");
map.put("customerType.corporate", "Corporate");
Customer customer = new Customer();
customer.setCustomerTypes(map);
request.setAttribute("customer", customer);
request.getRequestDispatcher("/Add.jsp").forward(request, response);
}
NB! i send map values into select tag in the Add.jsp page (simple user adding form), from where the data gets saved into database. And when the data gets saved the customerType
is in the form of customerType.corporate
or customerType.private
, but should be Corporate
or Private
.