有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    当然,您可以使用@Transient注释。例如:

    class MyClass{
    
        private int id;
        private String name;
    
        @Transient
        private int identity;
    }
    

    这里,identity字段在数据库中是暂时的,而不是持久的

    This means if a variable is marked @Transient then it won't be added in the database. it has no persistence representation of this variable in that hibernate session. After the session is closed these transient objects will be destroyed by garbage collection.