0

My User.hbm file is like this ,

<composite-id>
    <key-property name="username" type="java.lang.String">
        <column name="USERNAME"></column>
    </key-property>
    <key-property name="location" type="java.lang.String">
        <column name="LOCATION"></column>
    </key-property>
</composite-id>

User class is like this,

private String username;
private String location;

getter and setter I have overridden hashcode and equals method.

In my mvc form controller i am trying to display user related data

My jsp page

<div>
    <appfuse:label key="user.name" styleClass="desc"/>
    <form:input path="username" id="tag" cssClass="text medium" cssErrorClass="text  medium error"/>
</div>

My form controller.class

 @RequestMapping(method = RequestMethod.POST)
 public String onSubmit(User user, BindingResult errors,
                           HttpServletRequest request, HttpServletResponse response) throws Exception {
        LOG.debug("entering 'onSubmit' method ...");


        /////user.getUsername
    }

After i submit by form data , is getting added to the username

If i try to print user.getUsername it print name with , eg :,hello.

Can any one please explain why this happens how to solve it.? Is it related to composite id?

Davide Piras
  • 43,118
  • 10
  • 90
  • 143
constantlearner
  • 5,077
  • 7
  • 41
  • 62

2 Answers2

1

I think you need to create inner static class which should be mapped as Composite Id.

Mapping same class relation

Mapping same class relation - continuation

Please look at this questions and answers it may help.

Community
  • 1
  • 1
danny.lesnik
  • 18,305
  • 28
  • 125
  • 197
0

thanks i solved the issue.In hidden path i was using
<form:hidden path="userName"/>

<div>
    <appfuse:label key="user.name" styleClass="desc"/>
    <form:input path="username" id="tag" cssClass="text medium" cssErrorClass="text  medium error"/>
</div>

i removed hidden it solved issue

constantlearner
  • 5,077
  • 7
  • 41
  • 62