java - update Enum value in hibernate -


i wrote hql query want update enum value in database,but don't know how update enum value.this model

@entity public class imageinfo implements serializable{  @id @generatedvalue(strategy = generationtype.auto) @column(name = "id") private long id;  @column(name = "active") private integer active;  @column(name = "notification_num") private integer groupnum;  @column(name = "published_time") @temporal(temporaltype.timestamp) private date publishedtime;  @column(name = "posted_time") private timestamp postedtime;  @enumerated(enumtype.string) private publishindicator publishindicator;  } 

you can see there enum field named "publishindicator" . want update field in hql query.this query

session.createquery("update imageinfo img set img.active = 1  , img.publishindicator = :publish   img.active = 0  ,   img.publishedtime <:publishedtime ").setparameter("publishedtime",  date).setparameter("publish", publishindicator.publish).executeupdate(); 

but getting error

"java.lang.illegalargumentexception: node traverse cannot null!"

i know doing wrong updating enum valur.how can solve it?

use (fully qualified) publishindicator enum. instead of publishindicator.publish value, this: (assuming publishindicator enum in com.image package), use com.image.publishindicator.publish


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -