Announcement Announcement Module
Collapse
No announcement yet.
Spring + Hibernate <form:select> problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + Hibernate <form:select> problem

    Good day everyone!
    I encountered some problems while writting my project using Spring + Hibernate.
    For example, if two tables are joined as below:

    Code:
    <many-to-one name="studentAddress" class="com.vaannila.student.Address" column="STUDENT_ADDRESS" cascade="all" not-null="true" />
    Then how i am able to create a form for updating the relation with a <form:select > if the column STUDENT_ADDRESS (which is id) is already mapped to an OBJECT (not a type ) and <form:select > doesnt support "value" attribute with object in it

  • #2
    Write a custom property editor for com.vaannila.student.Address and register it with your controller's binder.

    Comment


    • #3
      Originally posted by JazonDin View Post
      Good day everyone!
      I encountered some problems while writting my project using Spring + Hibernate.
      For example, if two tables are joined as below:

      Code:
      <many-to-one name="studentAddress" class="com.vaannila.student.Address" column="STUDENT_ADDRESS" cascade="all" not-null="true" />
      Then how i am able to create a form for updating the relation with a <form:select > if the column STUDENT_ADDRESS (which is id) is already mapped to an OBJECT (not a type ) and <form:select > doesnt support "value" attribute with object in it
      Why do you need to pass the OBJECT in the <form:select>? Why don't you just pass the address as a String?

      For example, I'm gonna create a DTO object to be used by the JSP:

      StudentDTO
      ------------
      Integer id
      String firstName
      String lastName
      List<String> addresses

      StudentEntity
      -------------
      Integer id
      String firstName
      String lastName
      List<Addresses> addresses

      And use a mapping layer to map my Hibernate entity to the DTO

      Sample mapping logic
      --------------------
      StudentDTO student = map(studentDTO, studentEntity).

      Then pass this student to the JSP.

      Comment

      Working...
      X