How to map unidirectional @OneToMany with embeddedId in Hibernate

Solution Unverified - Updated -

Issue

  • We are trying to map two entities, with a @OneToMany association between two entities.
  • Class has a composite primary key, so we made an @EmbeddedId inside it.
  • How can we map in the right way a @OneToMany relationship with CascadeType=ALL, in order to make entityManager.persist(object) and entityManager.merge(object) working correctly? How to map these relationships in the right way, in order to make them work with persist and merge methods of entityManager.
  • Is it not possible to make it work with a unidirectional mapping? @OneToMany on Customer object, but without @ManyToOne in Product?

Environment

  • Red Hat JBoss Enterprise Application Platform
    • 6.2.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.