@ManyToOne

Example 1:

     @ManyToOne(optional=false) 
     @JoinColumn(name="CUST_ID", nullable=false, updatable=false)
     public Customer getCustomer() { return customer; }


     Example 2:
 
     @Entity
        public class Employee {
        @Id int id;
        @Embedded JobInfo jobInfo;
        ...
     }

     @Embeddable
        public class JobInfo {
        String jobDescription; 
        @ManyToOne ProgramManager pm; // Bidirectional
     }

     @Entity
        public class ProgramManager {
        @Id int id;
        @OneToMany(mappedBy="jobInfo.pm")
        Collection manages;
     }

 

你可能感兴趣的:(hibernate)