Is it somehow possible to tell Hibernate to override the primary key generated by a sequence on some condition?
For example i have an entity with this primary key - int:
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator="pk_seq") private Integer id;
normally im perfectly happy with this, so I can create objects and call:
session.save(Object);
and hibernate creates the primary key. but now i want to program a tool to import database entrys from csv-files, where the primary key that should be used is already specified:
id;day;month;year;time;historical;quality;att1;v1;att2;v2 1;12;09;2009;16:04:48;;;1;+26.3;2;34.27
so i create my objects:
Object o = new Object(); o.setId(1); ... but when i call session.save(o); hibernate uses the generated key instead of the one assigned. can i tell hibernate to generate a primary key only if none is assigned?
|