This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I'm new to JavaEE and I'm trying to write a servlet with a simple interface with MySQL. This servlet actually read the db without any problems but actually it doesn't write any change on db.
I've read the JavaEE tutorial but I cannot find useful thinghs about persistence in servlets.
My code is that:
The first two lines works properly because the value printed changes but the db remain unchanged.
This is the autogenerated code from NetBeans for the persist method:
but also a simple em.persist(object) doesn't work.
Can someone help me please? I use NetBeans with glassfish for develop.
I think there may be a couple of paths to look into:
- location? where is it in your app structure? META-INF?
- <class> </class> i think you need your class or package for your persistent entities declared here
- Hibernate; There may be some properties that need to be configured because you are specifically using the Hibernate provider.
Also, just something you may also want to do:
- extract your persistence calls to another class that you call from your Servlet.
- then you can write a unittest on that class to make sure the persistence is working.