• ray10k (unregistered)

    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!

  • aaaargh (unregistered)

    TRWTF is " View all 1 comments » "

  • Little Bobby Tables (unregistered) in reply to aaaargh

    You're just sore you didn't get to be Frist.

  • (nodebb)

    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.

  • snoofle (unregistered)

    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...

  • ZZartin (unregistered)

    The entire module it’s part of works and no one is entirely certain why.

    It's easy to see why it works, it returns a random UUid.

  • Chris L (unregistered)

    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!

  • (nodebb)

    I always generate 3-4 guids to make sure it's really random.

  • Little Bobby Tables (unregistered) in reply to Mr. TA

    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.

  • Bubba (unregistered)

    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...

  • Guesty Mc (unregistered) in reply to ZZartin

    Well, yes, it's obvious that it DOES work. And if the database uses H2Dialect, then the UUID returned is just MORE pseudo-random.

  • Perri Nelson (unregistered)

    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.

  • Hacky mc hackface (unregistered)

    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.

  • sizer99 (google)

    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

  • PedanticAntelope (unregistered)

    At least it doesn't actually create a map, just a field that could point to one.

  • jay (unregistered) in reply to Mr. TA

    "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.

  • matste (unregistered)

    TRWTF is that code written in 2016 is considered untouchable legacy.

  • Java for 20+ years (unregistered)

    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.

  • datanerd (unregistered)

    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.

  • Naomi (unregistered) in reply to PedanticAntelope

    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.)

Leave a comment on “Identify Yourself”

Log In or post as a guest

Replying to comment #501750:

« Return to Article