Code Snippet

Just another Code Snippet site

[Spring] Bind a View/Table without primary key

All fields must be declared as Id to “bypass” the PK/Id (mandatory for Spring).

Annotations @Entity and @IdClass must be set on class.
Annotation @Id must be set on each field.

@Entity
@IdClass(View.class)
@Table(name = "V_VIEW")
public class View implements java.io.Serializable {

    private String field1;

    private String field2;

    @Id
    @Column(name = "FIELD_1")
    public String getField1() {
        return field1;
    }

    @Id
    @Column(name = "FIELD_2")
    public String getField2() {
        return field2;
    }

,


Leave a Reply

Your email address will not be published. Required fields are marked *