JPA @version - can it be used to calcualate version of a table entry

Posted by OpenSource on Stack Overflow See other posts from Stack Overflow or by OpenSource
Published on 2010-05-20T19:36:41Z Indexed on 2010/05/20 19:40 UTC
Read the original article Hit count: 177

Filed under:
|
|
|

Hi,

Please consider the following table (created using a corresponding entity)

request
-------
id requestor type version items 
1  a         t1   1        5
2  a         t1   2        3
3  b         t1   1        2
4  a         t2   1        4
5  a         t1   3        9 

The above is what I want to achieve. The version field is a calculated field others are user provided. Basically the request's version needs to be calculated based on the combination of requestor and the type. The first occurance with a given combination will have a version 1 then version 2 and so on.

I tried various things using @version on a different entity with just the three columns and joining the two entities using ManytoOne etc but I'm not able to get to the desired outcome. I dont want to confuse you with the things I tried.

Since the objective is simple there should be an easier way I suppose? Can you please help? - any help greatly appreciated!

thanks in advance

© Stack Overflow or respective owner

Related posts about ejb3

Related posts about jpa