Announcement Announcement Module
Collapse
No announcement yet.
Probably a Newbie Question... But Here Goes Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Probably a Newbie Question... But Here Goes

    I have the following object model definition:
    Code:
    protected Sector  parent;
    	/**
    	 * @return Returns the parent.
    	 * @hibernate.many-to-one
    	 *   class = "uk.co.csspeople.model.Sector"
    	 *   column = "parent"
    	 */
    	public Sector getParent() {
    		return parent;
    	}
    Hibernate maps the relationship correctly, and the schema generated looks good too. However we running the FromController tests from AppFuse, I get the following:
    Code:
        [junit] ------------- Standard Error -----------------
        [junit] [Field error in object 'sector' on field 'parent': rejected value [n
    ull]; codes [typeMismatch.sector.parent,typeMismatch.parent,typeMismatch.uk.co.c
    sspeople.model.Sector,typeMismatch]; arguments [MessageSourceResolvable: codes [sector.parent,parent]; arguments []; default message [parent]]; default message
    [Failed to convert property value of type [java.lang.String] to required type [uk.co.csspeople.model.Sector] for property 'parent']]
        [junit] ------------- ---------------- ---------------
        [junit] Testcase: testSave(uk.co.csspeople.webapp.action.SectorFormControllerTest): FAILED
    I can't seem to find the documentation, but then I never liked manuals, to show how to do this kind of input binding. I was expecting that the test would supply null, no relationship end of... but that's not the way it seems to work. The DAOs and Managers test fine, just not the controller.

    If not should I go back to my original idea and store the links as Long(s) and use the managers to retrieve related objects?

    Any help would really be appreciated. Thank you in advance...

  • #2
    Code:
    [Failed to convert property value of type [java.lang.String] to required type [uk.co.csspeople.model.Sector]
    Have you supplied the property editor for uk.co.csspeople.model.Sector?

    If not, see Registering additional custom PropertyEditors.

    Comment


    • #3
      Originally posted by katentim
      Code:
      [Failed to convert property value of type [java.lang.String] to required type [uk.co.csspeople.model.Sector]
      Have you supplied the property editor for uk.co.csspeople.model.Sector?
      I haven't no. How do you write a CustomPropertyEditor which is basically to match to the PK of another persisted version of the same class?

      Comment


      • #4
        You just need the PK as a string, and get the PropertyEditor to look up the class in the DB. Take a look at Spring's source for CustomNumberEditor.

        Comment

        Working...
        X