Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6116179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:10:36+00:00 2026-05-23T15:10:36+00:00

I came across to problem with ManyToMany relations between Restaurant and Tag class. I

  • 0

I came across to problem with ManyToMany relations between Restaurant and Tag class. I got:

public class Tag {
    @Id
    private int id;
    private String name;
    @ManyToMany
    @JoinTable(name="restaurant_tag",
            joinColumns={@JoinColumn(name="tag_id")},
            inverseJoinColumns={@JoinColumn(name="restaurant_id")})
    private List<Restaurant> restaurants;

and:

public class Restaurant {
    @Id
    @GeneratedValue
    private int id;
    (...)
    @ManyToMany
    @JoinTable(name="restaurant_tag",
            joinColumns={@JoinColumn(name="restaurant_id")},
            inverseJoinColumns={@JoinColumn(name="tag_id")})
    private List<Tag> tags;

In my jsp I got:

<form:select multiple="true" path="tags">
<form:options items="${tagList }" itemValue="id" itemLabel="name" />
</form:select>

In my controller I got:

public ModelAndView myrestaurantadd(HttpServletRequest request,
            HttpServletResponse response, Restaurant restaurant)
            throws Exception {
restaurantDAO.saveRestaurant(restaurant);
}

When I click save button, I got error:

Field error in object ‘command’ on field ‘tags’: rejected value [[Ljava.lang.String;@5babd8cb]; codes [typeMismatch.command.tags,typeMismatch.tags,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [command.tags,tags]; arguments []; default message [tags]]; default message [Failed to convert property value of type [java.lang.String[]] to required type [java.util.List] for property ‘tags’; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [beans.Tag] for property ‘tags[0]’: no matching editors or conversion strategy found]] with root cause
org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:10:37+00:00Added an answer on May 23, 2026 at 3:10 pm
     [Failed to convert property value of type [java.lang.String[]] to required type [java.util.List] for property 'tags'; 
    

    How are you handling the object at your controller. You must be accepting java.util.List in the controller handler method whereas the actual object passed is String[]. Try handling it as String[] and convert it to List in you controller.

    EDIT:
    With regards to your comment, I suspected something of that sort. The tags are passed from jsp in form of String[] tag and you are catching a Restaurant object which would need a List and hence the error. Try the following

    public ModelAndView myrestaurantadd(HttpServletRequest request, HttpServletResponse response, Restaurant restaurant, String[] tags) throws Exception {
    //Convert the String array into List<Tag> and set this list in the restaurant object
    //Note that the Restaurant object obtained as the method argument with contain a null tag list, so you would need to set the tag list before saving
    //Save the Restaurant object now
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just came across a problem where the constructor of a class needs to
I'm doing some exercises and I came across a problem. I have got DLL
I was testing out covariant return types and came across this problem. class Vehicle
I came across this problem during an interview forum., Given an int array which
I came across this problem,I have got an algorithm that I need to implement
Came across a problem whereby I wanted the last time data was imported to
I came across this problem when I want to check what I input is
I came across a problem I cannot solve on my own concerning the downloadable
I came across this problem when trying to decode json into an array ,
i came across this problem, my code in the viewWillAppear method is not executed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.