|
I have a question. Can you please please please help me out?
I have following class.
Public class EntityBean implements Serializable {
private long id;
private String entityId;
private String entityVersion;
private String entityType;
private String entityText;
//getter-setter methods
}
1. id will represent the primary key.
2. I also have unique key constraint in database for entityId & entityVersion
Here is what I want to do, when I save entityBean, it should insert new row only if combination of entityId and entityVersion was not found in database (as it is unqiue-key)
If that combination was found then I do not want anything to be updated, but just id should be retrieved from database from corresponding row in database.
My questions are: 1. What should be hibernate mapping? 2. Should I use session.save or session.saveOrUpdate or session.merge or session.update method.
Any help is appreciated.
_________________ Hitesh Patel
WebInfo Software, Inc
|