I working at the moment on very excited project that uses Play 1.2, Camel, Guice and lot of black magic.
Surprisingly ,they do not work perfectly well with each other and they cause few troubles.
First major problem was with error message "The JPA context is not initialized due fact that I tried to use JPA during Play's startup stage.
Solution was using:
which didn't work for while until i ... restart STS.
Time to move on.
So everything almost works,except
epicItem.save() and .....
nothing happen in database.
There possible 3 solutions:
I tried this solution ...
where Andre Pareis said cascaded save() only works on loaded collections, so he suggestion solution:
I didn't use collection in this case,so guess what?
When I tried this solution ....
Nothing happens :).
I didn't give up .I have done more research and I found this:
where Dominik Dorn wrote that if you want save immediately ,then you need do:
This solution works for me!
It works,but it not fixes a problem,why ? Look of my code
.startTx(true) -I didn't check carefully and true means ... read only,which means ..it ignores my save() !
so... I needed to change .startTx(false)
- Make sure ,that your current transactions is not in read only mode!
- If you use cascade operation.Make sure ,that all essential collections are loaded.
- In case of emergency use: JPA.em().flush(); JPA.em().getTransaction().commit();
- Be careful,when you do 'try everything,so maybe something will works'
btw. It another time,when i solve Play Framework issue 10 minutes before end of the work, which I found annoying as I fight half day and I feel so upset.It seems I don't have luck with Play 1.2 and JPA stuff :/