Java check if data exists on DB
<p>I have a rest web service with calls in post (i want to write a new entity on the DB) like this:</p>

<p><a href="http://localhost:8080/rest/accounts/id_account/order" rel="nofollow">http://localhost:8080/rest/accounts/id_account/order</a></p>

<p>and the controller method is this one:</p>

<pre><code>@POST
@Path("/{accountid}/orders")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
public Response addOrder(
        @Valid Order order,
        @NotBlank @PathParam("accountid") String accountId);
</code></pre>

<p>This method should write a new order in the DB.</p>

<p>Everything is simple but I want to check if the entity account with id = id_account exists in the DB, using annotation.</p>

<p>I cannot use a simple validator because is not transactional, so i cannot be sure that the entity account exists when I perform the request.</p>

<p>Is there a way to write a transactional annotation or something similar?</p>

<p>I'm using spring mvc and Jaxrs.</p>

<p>Thanks!</p>