Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Modifying
- @Query("update Computer com set com.enabled=!com.enabled where com.id = ?1")
- private Boolean enabled;
- public Boolean getEnabled() {
- return enabled;
- }
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
- 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]
- spring.datasource.url=jdbc:h2:mem:testdb;MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE
- spring.datasource.username=sa
- spring.datasource.password=
- spring.jpa.show-sql=false
- spring.jpa.properties.hibernate.format_sql=true
- hibernate.dialect=org.hibernate.dialect.H2Dialect
- @Converter(autoApply=true)
- public class GlobalBooleanConverter implements AttributeConverter<Boolean, Integer>{
- @Override
- public String convertToDatabaseColumn(Boolean value) {
- if (Boolean.TRUE.equals(value)) {
- return Integer.valueOf(1);
- } else {
- return Integer.valueOf(0);
- }
- }
- @Override
- public Boolean convertToEntityAttribute(String value) {
- return Integer.valueOf(1).equals(value);
- }
- }
- @Modifying
- @Query("update Computer com set com.enabled=((-com.enabled)+1) where com.id = ?1")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement