- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Well obviously, it's futureproof! You never know when some dashing rogue of a SQL dialect suddenly becomes super popular with its exciting new way of handling UUIDs!
Admin
TRWTF is " View all 1 comments » "
Admin
You're just sore you didn't get to be Frist.
Admin
Clearly session.getFactory().getDialect() has been overridden and does different things depending on how many times it's been called, which is why it can't be touched.
Admin
Fast forward to the inevitable rewrite...
So what does this module do?
We don't know and can't figure it out!
Ok, so the schedule says you must deliver the replacement code in two weeks...
Admin
It's easy to see why it works, it returns a random UUid.
Admin
Just thinking of all the UUIDs they're wasting.
Pretty soon the activists will become concerned. Then they'll start agitating for conservation. They'll petition Congress to create laws to mandate we recycle UUIDs. The news media will run stories discussing how concerned scientist are that we may run out UUIDs at some point in the future. Think Of The Children!
Admin
I always generate 3-4 guids to make sure it's really random.
Admin
Nah. You only need to run it twice. To make sure it's working. Then what you do is, you compare the two values. If they're not the same, something's going wrong, so sleep a few seconds, and then try it again. Sooner or later the code will work.
Hey, it's taking a long time for this loop to exit, perhaps I need a faster computer.
Admin
Is Remy the only one working here any more?
The only reason I come here is in the hope of seeing an article by anyone but Remy....gimme some Snoofle, Jane, Ellis or Charles...
Admin
Well, yes, it's obvious that it DOES work. And if the database uses H2Dialect, then the UUID returned is just MORE pseudo-random.
Admin
Just think of all of the side effects of calling all those functions. This is like a delay loop that can be removed later to "optimize" the code.
Admin
No-one mentioning it returns serializable. That interface with all those methods. What object did i generate? I dunno but you can apparently represent it with a byte stream. Useful.
Admin
I'm guessing the unused map came from a plan to have a cache of UUIDs (which would have other issues) that never got implemented. You know, for efficiency, so you can generate millions of non-random UUIDs per second. koff
Admin
At least it doesn't actually create a map, just a field that could point to one.
Admin
"I always generate 3-4 guids to make sure it's really random."
You should randomly generate 3-4 guids, and then pick one of them at random.
Admin
TRWTF is that code written in 2016 is considered untouchable legacy.
Admin
The reason it returns Serializable is because it's enough for Hibernate to use it for a primary key, different implementations of the IdentifierGenerator interface would then return different actual objects.
The code is of course stupid, I bet it was someone who tried to cover imaginary edge cases, and the code was forgotten.
Admin
the real WTF here is that a UUID is the worst possible choice of data type for primary key in relational database. generating more unique and random UUIDs has no impact on the actual issue caused by this crap code: query performance, specifically performance of joins.
Admin
You'd think that, but this class looks to be instantiated through Spring, which will provide @Resources and @Values automatically. (Broadly speaking, if you see @Whatever in Java code, and it's not @Override, @Deprecated, or @SuppressWarnings, some kind of framework's being used - and Java frameworks do all kinds of useful-and/or-crazy things.)