Showing posts with label Hibernate. Show all posts
Showing posts with label Hibernate. Show all posts

Saturday, 3 March 2012

Developer Diary - Flex, Hibernate & Serialisation

From 11th September 2011.
Been keeping busy learning all the ins and outs of Flex, Hibernate and the perils of serialisation!

I'm sure everyone else knows but you should never assume things will "just work". There is no magic hammer for all problems and deserialisation is definitely something to be careful with.

Anyway, long story short, once you define the relationships on your data, Hibernate can load your database rows into neat little collections. Problem is that these collections are custom ones built by Hibernate, such as the PersistanceMap.

The problem arises when you attempt to send these down the wire to a Flex front end. GaS3 cannot serialise Hibernate collections properly and all you get out of the other side are nulls :(

This bug must have taken me about 2 weeks on and off to get to the root of >.< I kept finding work arounds but I finally sat down the other day to try to understand it. Mission accomplished... So yay XD

Things can be rough when you try to learn multiple complex technologies on the job!

Developer Diary - Hibernate Generated Primary Key Values

From 16th August 2011.

Ever since I started using Hibernate, I have noticed some weird behaviour with the primary keys that were being generated. They were way too high and being incremented strange multiples.

This bugged me personally, it wasn't causing any sort of bug in the code but I was determined to get to the root cause of the problem.

Turns out you have to tell Java Persistence not to multiple your sequence generator by 50! Why this default logic is in place, I don't know...

More details here ^_^ Spread the word!