Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@javax.persistence.Column( updatable=false )

If I define a field as non-updatable, does that mean that the field can't be updated at all, ever? What I'd like to do is prevent the field from getting updated when I save an entire entity object, but still be able to write queries that explicitly update this field. Is this possible?

I'm using Hibernate and MySQL, but I'd prefer to write portable code.

like image 411
Mike Baranczak Avatar asked Aug 16 '12 18:08

Mike Baranczak


1 Answers

@javax.persistence.Column( updatable=false )

The column mapped would not be updatable using HQL or via hibernate methods. In case you need to update the value in the DB you should be writing native SQL.

And if I see logically, it shouldn't allow you to update when you say updatable=false

like image 79
Bharat Sinha Avatar answered Sep 28 '22 22:09

Bharat Sinha