Both EJB3 and Hibernate are following Java Persistence API. This sample using hibernate to show you: one2many, one2one, many2many, composite key