开发者

Alternative of JPA

I want to use JPA for my persistence layer of my Java Desktop Application but I have the similar problem as describe at JPA - Entity design problem

I d开发者_如何学JAVAidn't find a solution to the above kind of problem that's why I want to go with any other alternative of JPA.

It would be better if I get the solution of the above problem.


IMO the proper way to deal with such issues would be to use a generated internal (typically Long) ID instead of a natural primary key - this eliminates the whole problem. Of course, this requires a modification of your DB schema. I included an example mapping in my answer to the other post.

If this isn't possible, and the referred solution is not satisfactory to you (btw why?), you might try Hibernate, which offers a superset of JPA functionality (although I can't offer a solution with Hibernate out of the top of my head - especially without knowing what your problem is with the JPA solution).


Things work beautifully if you let jpa assign an id (eg integer) as a primary key for your objects. The complications in the example you mentioned are only because of the constraints that author had on primary keys


As one of the other answers says, generate an "internal" (surrogate) key ... aka "datastore" identity. This is part of the JDO specification (JPA only supports application identity, whereas JDO supports datastore and application identity).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜