@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<Employee> manages;
     }
发布了476 篇原创文章 · 获赞 3 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_37769323/article/details/104881094