These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Unique Key Constraints
PostPosted: Thu Oct 05, 2006 12:20 pm 
Newbie

Joined: Thu Oct 05, 2006 12:15 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.