JPA ManyToMany constraints?

Since you are using JPA, which is an Object-Relational mapper, design it as you would if JPA and Databases were not involved.

Since you are using JPA, which is an Object-Relational mapper, design it as you would if JPA and Databases were not involved. What I mean is build your object model (java classes) in the way that would make sense for the objects and relationships you are trying to capture- then worry about configuring JPA correctly around those objects. The last time I used JPA it was around the time 2.0 was being rolled out, so I don't remember how throughly the specification supports using fields that are implementations of java.util.

Map, but a Map would be a good way to go if it is supported. Specifically, in your Product object you could have a field of type Map. Map votesOnThisProduct; But honestly, whatever feels the most rational when you think about it from the perspective of java classes only, ignoring JPA and database mindsets, is the way to go.

Other options would be to define additional classes, such as public class ProductVoteRecord { User user; Vote vote; Product product; } and then make User and Product (and possibly vote) a compound primary key via JPA annotations. But even a class like that shows signs of being poisoned by relational design, since it is essentially a joiner table.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions