Hi to all, i have question about business key.
I'm a little confuse about this concept. I have worked with old schema db always with composite id
Now i'm to going to develop a new software, and i will use hibernate 3. In this day i'm reading about persitence and surrogate key and i have some question to post you:
I take this simple class
Customer
pkid
cod_id
description
email
version (long or timestamp)
1) pkid is my surrogate key (native, sequence etc)
2) email is my business key
Ok now my question:
1) When i will use Hibernate saveOrUpdate, hibernate check my pkid for insert or update my record into database (dao.SaveOrUpdate(pojo))
Here i have difficult to understand how to do:
But if my business key is the email, i can't call SaveOrUpdate, is it correct?
Then i don't know the best approach for to check my bkey, I think into my dao class to implement this:
.....
check if exists this email into db with a simple hql or Criteria
and then to use SaveOrUpdate
....
Can you help me to understand how to use Business key with hibernate please. I have read Equals/HashCode but i have no idea when hibernate call this function
Thanks in advance for your help
Devis
|