Hibernate not ingoring @Transient field

110 Views Asked by At

I have an entity that derives from an interface that defines a getter method. I mark it with @Transient, but still hibernate requires me to

  1. Define a setter method.
  2. Does include the field in all queries, causing a crash.

Isn't that what @Transient is for?

public interface Archiveable { @Transient Boolean getArchived(); }


@Entity
@Table(...)
public class Post implements Archiveable {
    
    @Override
    @Transient
    public Boolean getArchived() {
        return false;
    }
}

I am pretty sure i am using this very construct in other forms as well.

1

There are 1 best solutions below

3
Georgii Vlasov On

The @Transient annotation can be applied only to the fields, not the method definitions.