Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to resolve this message -Failed to convert property value of type java.lang.String to required type
    primarykey
    data
    text
    <p>I was building an simple application using spring roo. After doing certain job, I have removed roo completely.</p> <p>So here is my controller methods for creating new data.. </p> <pre><code>@RequestMapping(params = "form", produces = "text/html") public String createForm(Model uiModel) { populateEditForm(uiModel, new PatientDetails()); return "patientdetailses/create"; } @RequestMapping(method = RequestMethod.POST, produces = "text/html") public String create(@Valid PatientDetails patientDetails, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { if (bindingResult.hasErrors()) { populateEditForm(uiModel, patientDetails); return "patientdetailses/create"; } uiModel.asMap().clear(); patientDetailsService .savePatientDetails(setCurrentUser(patientDetails)); return "redirect:/patientdetailses/" + encodeUrlPathSegment(patientDetails.getId().toString(), httpServletRequest); } void populateEditForm(Model uiModel, PatientDetails patientDetails) { uiModel.addAttribute("patientDetails", patientDetails); addDateTimeFormatPatterns(uiModel); uiModel.addAttribute("sexes", Arrays.asList(Sex.values())); uiModel.addAttribute("typeOfPatients", typeOfPatientService.findAllTypeOfPatients()); } </code></pre> <p>my domain: </p> <pre><code> public class PatientDetails { @NotNull @NotBlank @NotEmpty @Size(max = 40) private String firstName; @NotNull @NotBlank @NotEmpty @Size(max = 40) private String lastName; @Size(max = 40) private String middleName; @Size(max = 200) @NotNull @NotBlank @NotEmpty private String address; @NotNull @NotBlank @NotEmpty private String city; @NotNull private String province; @NotNull @Size(max = 5) private String postalCode; @NotNull @Email @Size(max = 100) private String email; @Size(max = 12) private String homePhone; @Size(max = 12) private String workPhone; @NotNull private Sex sex; @Past @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(style = "M-") @NotNull private Date dateOfBirth; @NotNull @Size(max = 10) private String socialSecurityName; @NotNull @Size(max = 100) private String occupation; @ManyToOne private TypeOfPatient typeOfPatient; @ManyToOne private User users; } </code></pre> <p>and the views : </p> <pre><code> &lt;div xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields" xmlns:form="urn:jsptagdir:/WEB-INF/tags/form" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:spring="http://www.springframework.org/tags" version="2.0"&gt; &lt;jsp:directive.page contentType="text/html;charset=UTF-8"/&gt; &lt;jsp:output omit-xml-declaration="yes"/&gt; &lt;form:create id="fc_com_simplemed_npc_domain_PatientDetails" modelAttribute="patientDetails" path="/patientdetailses" render="${empty dependencies}" z="8/olU0ivxZlcCzNCDYriOP+hE2U="&gt; &lt;field:input field="firstName" id="c_com_simplemed_npc_domain_PatientDetails_firstName" required="true" z="user-managed"/&gt; &lt;field:input field="lastName" id="c_com_simplemed_npc_domain_PatientDetails_lastName" required="true" z="user-managed"/&gt; &lt;field:input field="middleName" id="c_com_simplemed_npc_domain_PatientDetails_middleName" z="user-managed"/&gt; &lt;field:textarea field="address" id="c_com_simplemed_npc_domain_PatientDetails_address" required="true" z="0CYYBU4YKijB7hQ3Npq7QXHb2ys="/&gt; &lt;field:input field="city" id="c_com_simplemed_npc_domain_PatientDetails_city" required="true" z="pQoSTWOVKlwKWZV5OlKvsCwQt6M="/&gt; &lt;field:input field="province" id="c_com_simplemed_npc_domain_PatientDetails_province" required="true" z="7hzMJ6GrQfV6YMHTSNpUIw2z508="/&gt; &lt;field:input field="postalCode" id="c_com_simplemed_npc_domain_PatientDetails_postalCode" max="5" required="true" z="QttQ/Av8Y2LXLPjpc88NRqtu7kI="/&gt; &lt;field:input field="email" id="c_com_simplemed_npc_domain_PatientDetails_email" required="true" validationMessageCode="field_invalid_email" z="user-managed"/&gt; &lt;field:input field="homePhone" id="c_com_simplemed_npc_domain_PatientDetails_homePhone" max="12" z="pBKxDLFxHZKsvHUjMqozutbbkug="/&gt; &lt;field:input field="workPhone" id="c_com_simplemed_npc_domain_PatientDetails_workPhone" max="12" z="LViJ3WNDosJPBWk6AGJmcZrnjfw="/&gt; &lt;field:select field="sex" id="c_com_simplemed_npc_domain_PatientDetails_sex" items="${sexes}" path="sexes" required="true" z="OjuzCMOizRZlHrPGgWVrV6wnR0k="/&gt; &lt;field:datetime dateTimePattern="${patientDetails_dateofbirth_date_format}" field="dateOfBirth" id="c_com_simplemed_npc_domain_PatientDetails_dateOfBirth" past="true" required="true" z="tthi2TXacQkSlyRj+QX9HsbzaIs="/&gt; &lt;field:input field="socialSecurityName" id="c_com_simplemed_npc_domain_PatientDetails_socialSecurityName" max="10" required="true" z="lKuMt6y/W4VI1dJEiW3gk5ZvK3c="/&gt; &lt;field:textarea field="occupation" id="c_com_simplemed_npc_domain_PatientDetails_occupation" required="true" z="WfCTmH7Nkt3bMfkJ1HNpkqe+aa8="/&gt; &lt;field:select field="typeOfPatient" id="c_com_simplemed_npc_domain_PatientDetails_typeOfPatient" itemValue="id" itemLabel="patientTypeName" required="true" items="${typeOfPatients}" path="/typeofpatients" z="Uj2xfoaPX5/gkwXb9WBxdzAfN/4="/&gt; &lt;/form:create&gt; &lt;form:dependency dependencies="${dependencies}" id="d_com_simplemed_npc_domain_PatientDetails" render="${not empty dependencies}" z="OEZW6AYtVJ5mEmMbn24lHjWtPp4="/&gt; </code></pre> <p></p> <p>I'm getting errors while submitting forms <img src="https://i.stack.imgur.com/ZWBTu.png" alt="enter image description here"></p> <p>Can anyone please help me on this... </p> <p>Thanks in Advance. </p> <p>Edit: </p> <p>TypeOfPatient Class: </p> <pre><code> public class TypeOfPatient { @NotNull private String patientTypeName; @NotNull @Size(max=1024) private String decriptions; @Override public String toString() { return patientTypeName; } </code></pre> <p>}</p> <p>My Conversion Code : </p> <pre><code> @Autowired TypeOfPatientService typeOfPatientService; public Converter&lt;String, TypeOfPatient&gt; getStringToTypeOfPatientConverter() { return new Converter&lt;String, TypeOfPatient&gt;() { @Override public TypeOfPatient convert(String id) { return typeOfPatientService.findTypeOfPatient(Long .parseLong(id)); } }; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload