Good day. There is a hibernate Entity:

@Entity @Table(name = "photos") public class Photo { @Id private long id; private String linkLocation; private byte[] data; @OneToOne(mappedBy = "photo") private Customer customer; 

It is necessary that the byte field is not included in the database.

    1 answer 1

    Use the @Transient annotation. It will mean that the field will not be persistent, i.e. will not be saved in DB. And, accordingly, it will not be filled with a value when receiving an object from the database.

     @Transient private String name; public String getName() { return name; } private void setName(String name) { this.name = name; } 
    • Only gett method? I marked all 3) Is it wrong? - Nikolay Egorov
    • @ Nikolay Egorov, you can only mark the field itself with annotation, then the getter and setter can be written as usual) - Ksenia
    • I did this: Trannsient field, Traensient get, Transient set. I just did Transient get - there is a column in the database ... I just tried the Transient field - the same thing .... - Nikolay Egorov
    • Everything ... Earned. I marked only the field and it works, although I’m kind of tried it before) Thanks, in any case - Nikolay Egorov