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?