Hibernate_ Adding a contact practice

Source: Internet
Author: User

Analysis:

Contact and customer is many to one, a customer (company) has multiple contacts, on the more this side, namely Linkman,

1, Linkman.java In addition to their own attributes, but also need

2. In the Hbm.xml file, add

This means that a foreign key is established to maintain the relationship, the column name is lkm_cust_id, the referenced property name is the customer object defined in Linkman.java, and the class of the object is Customer.java

Realize:

1. New Addlinkmanservlet

2. New service and Impl

3. DAO and Impl,customerdao Add GetByID method

The ID information of the customer submitted by table dropdowns is encapsulated into the Linkman object, the customer object is obtained through the client's ID in Serviceimpl, the acquired customer object is saved to the Customer object in the Linkman object, and finally, Saved to the database through the DAO layer implementation.

Hibernate_ Adding a contact practice

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.