JPA composite primary key


This question already has an answer here:


Recently I created ManyToMany relation using Composite Primary key and annotation as bi directional @OneToMany. This code works flawless. Maybe it will help:

Mapping ManyToMany with composite Primary key and Annotation:

Since you are using @IdClass, the PricePK class need not be marked with the @Embeddable annotation. An example is given in

I tried your code removing the @Embeddable on PricePK class, and the price table generated in MYSQL database with not null fields.

Following is how you could use @EmbeddedId to achieve the required result: (getters and setters omitted)

@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Price {

    PricePK pricePk;

public class PricePK implements Serializable {

    @ManyToOne(optional = false)
    private Product product;

    @ManyToOne(optional = false)
    private Currency currency;

Need Your Help

keep link style when changing page Javascript

javascript html css hyperlink styles

im using Smarty and php4(cant upgrade =( ).On my site on the left, i have a navigation-column with all my links. I want the link which i click to change color to RED and STAY RED until i click anot...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.