Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. @Modifying
  2. @Query("update Computer com set com.enabled=!com.enabled where com.id = ?1")
  3.  
  4. private Boolean enabled;
  5.  
  6. public Boolean getEnabled() {
  7. return enabled;
  8. }
  9.  
  10. public void setEnabled(Boolean enabled) {
  11. this.enabled = enabled;
  12. }
  13.  
  14. Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: expecting '=', found 'c' [update com.nicinc.Computer com set com.enabled=!com.enabled where com.id = ?1]
  15.  
  16. spring.datasource.url=jdbc:h2:mem:testdb;MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE
  17. spring.datasource.username=sa
  18. spring.datasource.password=
  19. spring.jpa.show-sql=false
  20. spring.jpa.properties.hibernate.format_sql=true
  21. hibernate.dialect=org.hibernate.dialect.H2Dialect
  22.  
  23. @Converter(autoApply=true)
  24. public class GlobalBooleanConverter implements AttributeConverter<Boolean, Integer>{
  25. @Override
  26. public String convertToDatabaseColumn(Boolean value) {
  27. if (Boolean.TRUE.equals(value)) {
  28. return Integer.valueOf(1);
  29. } else {
  30. return Integer.valueOf(0);
  31. }
  32. }
  33. @Override
  34. public Boolean convertToEntityAttribute(String value) {
  35. return Integer.valueOf(1).equals(value);
  36. }
  37. }
  38.  
  39. @Modifying
  40. @Query("update Computer com set com.enabled=((-com.enabled)+1) where com.id = ?1")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement