Search Results

Search found 2 results on 1 pages for 'plouh'.

Page 1/1 | 1 

  • How to introduce multi-column constraint with JPA annotations?

    - by plouh
    I am trying to introduce a multi-key constraint on a JPA-mapped entity: public class InventoryItem { @Id private Long id; @Version private Long version; @ManyToOne @JoinColumn("productId") private Product product; @Column(nullable=false); private long serial; } Basically (product, serial) pair should be unique, but I only found a way to say that serial should be unique. This obviously isn't a good idea since different products might have same serial numbers. Is there a way to generate this constraint via JPA or am I forced to manually create it to DB?

    Read the article

  • How to use multiple restrictions in C# Generics properly?

    - by plouh
    I am attempting to bind c# generics to a class and an interface like this: public class WizardPage<T> where T : UserControl, IWizardControl { private T page; public WizardPage( T page ) { this.page = page; } } And use it with this: public MyControl : UserControl, IWizardControl { //... } Somehow C# doesn't seem to be able to decide that MyControl is a proper instance of T as public class Wizard<T> where T : UserControl, IWizardControl { private WizardPage<T> Page1; public Wizard( MyControl control ) { this.Page1 = new WizardPage(control); } } fails with error The best overloaded method match for 'Controls.WizardPage.WizardPage(T)' has some invalid arguments Am I doing something wrong or is this just not going to work?

    Read the article

1