This may seem a silly question but:
If I have an object similar to below, and use JPA/hib to create the id.
@Entity
public class Item {
@Id @GeneratedValue
private Long id;
private String name;
... getters/setters ...
}
then do:
Item item1 = new Item();
item1.setName("Test Name");
em.persist(item1);
Item item2 = new Item();
item2.setName("Test Name");
em.persist(item2);
Given that it's created OK on the database with 2 new rows on the item table, how can I sync whats in the 2 objects in memory against whats now in the db. i.e. how do I get the generated id's back into the item objects ?
Thanks,
|