-->
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: Determining object equality without primary key
PostPosted: Tue Jun 19, 2007 11:46 pm 
Newbie

Joined: Wed Oct 18, 2006 9:39 pm
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

Hi,

I have an address object with id as primary field.

Class address {
long id // primary key -- oracle sequence
// Other fields are address1, address2, city, state , zip
equals(){
// based on all the fields except the id field
}


Use case :
a) The address sent by the client is is saved in the database
b) The client will be sending all the fields in the address object except ID

1) How to avoid duplicate address? (ie) if the client sends the same address twice, then I don't want it to save it twice. Also I don't want to do a sql select to determine whether this address is in the table since it will be costly to do it

2) Address object is using ehcache. So most of the rows will be in ehcache. Only difference is the objects in ehcache will have ID attribute set to some value, whereas my object won't have ID attribute.

3) I can do this by creating my own cache of TreeSet and adding the address object in cache. Is there an elegant way to do this?


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.