0

I have to insert product details. I have multiple bean classes which are generated from tables but all the fields are in a single html form. How could I map those form elements to different bean classes and how could I get those form elements in controller?.

My Bean classes are

Category
    private Long id;
    private String description;
    private String name;

ProductAttribute 
    private String description;
    private String name;

CategoryAttributeMapping
    private Category category;
    private ProductAttribute productAttribute ;

Could any one help me?

0

1 Answer 1

1

You can make some kind of proxy Object that has all of those fields, map the path in the HTML form to that object and in some service layer, you can break it in those 3 Entity classes and save them in the Database.

And on a side note(IF you're using Hibernate), what you have there is @ManyToMany (i suppose) mapping. You don't need to create the 3rd class to map those 2 Entities.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.