In my discovery of tynamo and resteasy integration, I'm facing an issue on saving datas, that I partially solved (so I will partially share it ;) ). User guide is here : http://docs.codehaus.org/display/TYNAMO/tapestry-resteasy+guide
I wrote a rest service that allow "users" registration in my system users :
package com.myorg.mobile.pushup.rest;
//[...]
/**
* bla blah obfuscated pretty comments.
*
* @author jrrevy
*
*/
@Path("/user")
public class UserResource {
private Session session;
/**
* Constructeur du service
*
* @param session
* Hibernate session
*/
public UserResource(Session session) {
this.session = session;
}
/**
* Lecture de tous les utilisateurs
*
* @return une liste des utilisateurs existants
*/
@GET
@Produces("application/json")
public List<User> getAllDomains() {
return session.createCriteria(User.class).list();
}
/**
* Create User.
*
* @param user
* user to create
* @return a Web Response
*/
@POST
@PUT
@Produces({ "application/xml", "application/json" })
public Response createOrUpdate(User user) {
session.saveOrUpdate(user);
return Response.ok().build();
}
Access to database works well (I get my users back, an saw INSERT INTO command into the logs), but this service never persists anything. It seems that the transaction is never commited.
I'm using 0.3.0 version of tapestry-model-hibernate and tapestry-resteasy :
<dependencies>
<dependency>
<groupId>org.tynamo</groupId>
<artifactId>tapestry-model-hibernate</artifactId>
<version>0.3.0</version>
</dependency>
<dependency>
<groupId>org.tynamo</groupId>
<artifactId>tapestry-resteasy</artifactId>
<version>0.3.0</version>
</dependency>
</dependencies>
See my answer above, but please tell me if you found a better way.