1. saveOrUpdate using alternate keys? forum.hibernate.orgAs far as I understood, Hibernate is applying a simple strategy to determine whether an object is new or exists in the database: if it has an ID set, then it exists, otherwise it is new. This status determines whether saveOrUpdate would result in an INSERT or UPDATE statement. In many cases for me, this is not sufficient. For example, a ... |
2. saveOrUpdate w/ Surrogate Key. Detect Dup Based On Nat. Key? forum.hibernate.orgI have an entity where the natural id is made up of 3 columns. Since there are many relationships to and from this entity, Ive simplified my data model and Hibernate config (allegedly) by using a surrogate key. In the UI users can create new instances of this entity, add some child objects and, based on the natural id, they can ... |
3. saveOrUpdate using NaturalID with Surrogate Primary Key forum.hibernate.orgHibernate version: 3.3.1GA Mapping documents: Code: @Entity public class DefaultInstrument implements Instrument { @Column(length = 6, nullable = false) String groupCode; @NaturalId(mutable = false) @Column(length = 6, updatable = false, nullable = false) String productCode; // This is nullable because this value is ... |