Results 1 to 4 of 4

Thread: Probably a Newbie Question... But Here Goes

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    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.

  3. #3

    Default

    Quote 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?

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    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.

Similar Threads

  1. Newbie question: How to get spring debug logging on?
    By wangjammer5 in forum Container
    Replies: 2
    Last Post: Jul 15th, 2005, 07:11 AM
  2. Replies: 1
    Last Post: Jul 11th, 2005, 03:50 PM
  3. Replies: 3
    Last Post: Jul 8th, 2005, 09:00 AM
  4. Replies: 3
    Last Post: Apr 3rd, 2005, 04:34 PM
  5. Replies: 1
    Last Post: Mar 23rd, 2005, 07:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •