Runtime proxy generation creates Hibernate proxy classes during execution to defer loading entity associations. The domain classes need no special supertype, bytecode post-processing, or build-time code generation. section 12.1.1
Use proxies with these lifecycle and modeling constraints:
- Avoid assuming proxy classes equal entity classes, direct field access in equals() or hashCode(), or lazy loading for basic and embedded properties. section 12.1.1
Persisting a bid without loading referenced entities
Obtain Item and User with em.getReference(), assign them to a new Bid, and call em.persist(). Hibernate can queue the BID INSERT using proxy identifiers without issuing SELECT statements.
