Is it possible for a JPA entity to have a field which is not mapped to any column in the data base table. Basically I need to store some additional data on my front end but I do not want to create an extra column in the table for this.
            Asked
            
        
        
            Active
            
        
            Viewed 1.3k times
        
    12
            
            
        - 
                    2this is a duplicate question. https://stackoverflow.com/questions/4662582/make-hibernate-ignore-class-variables-that-are-not-mapped – yerqueri Oct 23 '18 at 07:07
 
2 Answers
18
            
            
        Just mark the field or getter with @javax.persistence.Transient annotation.
The data stored there will not be persisted, nor the ddl generator, if you use any, will pick that one up as an additional column of the table.
        Maciej Kowalski
        
- 25,605
 - 12
 - 54
 - 63
 
3
            
            
        Marking @Transient annotation solve this problem but it will work after restart host server(application/web).
        Kumar Aditya
        
- 189
 - 1
 - 1
 - 13