hey Joe,I found this useful for some work I'd been doing today, so I thoughtI'd leave a comment and say thanks. We were trying to persist a statepattern implemented in a stateless way, with an abstract state classbeing extended for multiple states. We have managed to argue our wayinto restructuring the state model as a java 5 Enum that has methodsthe state transition methods implemented like:http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.htmlThis appears to be persisted by hibernate as an integer, without theneed to create a user type, which we felt was a quicker and easiersolution, as the EJB3 world is all a bit new to most of thedevelopment team.
Thanks for dropping by my blog.> the EJB3 world is all a bit > new to most of the> development team Hehe, just be thankful they don't have to learn EJB2!
Hi Joe. I too found this a useful piece based on attempting to implement the State Pattern from the book with the nice girl on the cover :O)The problem I could not crack was the fact the pattern actually instantiates the states within the entity and passes a 'this' reference in to each state constructor. You provide an alternative which is to pass the entity reference (e.g. Customer) in to the action method (e.g activate). A nice touch but I wish to retain the original pattern structure since it is cleaner for my requirement: my different states sometimes transition the entity state bit sometimes do not require to do so.I cannot see any way to use Hibernate UserType to retain the exact pattern implementation but let me know if you think otherwise.Cheers, Cam
org.hibernate.MappingException: Could not determine type for: OrderStateUserTypewhere i have put OrderStateUserType when i have complicate structure?
i got something useful from your blog. thank u
Post a Comment
Rants, raves, comments and tips about computer hardware and software -- from a software developer's point of view.