I have a question about hibernate.
I want to save a small graph of detached objects :
session.save(new City(1));
Peron p = new Person(new City(1), new Street(2));
session.save(p);
Hibernate told me that city is transient but I do :
session.refresh(city);
session.refresh(street);
session.update(p);
Any Idea?
Either do something like this:
Or setup cascading to cascade the
saveoperation. For example, with annotations:And then the code becomes:
References