开发者

How to store model information in spring mvc with hibernate

I need advice how to store model in spring mvc 3 with HIbernate (example on ilustration)

I have model

public class Customer{
        int id;
        String name;
        String surname;
        ArrayList<Contact> contacts;
...
getters, setters
}

Here is class Contact

public class Contact{
            int id;
            String address;
            String phonenumber;

    ...
    getters, setters
    }

You can see a Model h开发者_JS百科as array list which contains contact information for Customer, When I am creating new customer i type name and surname to input fields and from existing contacts list I want to add contact for customer. (Add contact to ArrayList). And show selected contacts in view My question is how to remember what is already added to ArrayList contacts.

I should use Session, or temp file or hidden field in view or something else? What is best solution?

Thanks


you can keep a list of ids of all of the contacts that already exist in for the current customer.

you can query the db to get a list of contacts that don't have a relationship with the current customer id. (would need to see more of your model to finish that thought)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜