Home > AI > Backend > SpringBoot > mysql-connector-java >

@AttributeOverride

override the attribute name in the parent class

Example 1:

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name="basic_students")
@AttributeOverride( name="createDate", column = @Column(name="std_create_date") )
public class BasicStudent extends BasicParent {
    private static final long serialVersionUID = 1L;

    @Column(name="first_name")
    private String firstName;

    @Column(name="age")
    private int age;

}

Example 2:

Vehicle.java

@MappedSuperclass
public class Vehicle {
    @Id
    @GeneratedValue
    private Integer id;
    private String identifier;
    private Integer numberOfWheels;
    
}
@Entity
@AttributeOverride(name = "identifier", column = @Column(name = "VIN"))
public class Car extends Vehicle {
    private String model;
    private String name;

}

Leave a Reply