简体   繁体   English

为什么SqlExceptionHelper将布尔约束违反解释为\\ x00

[英]Why does SqlExceptionHelper interpret boolean constraint violation as \x00

I have the following domain object 我有以下域对象

@Table(uniqueConstraints={@UniqueConstraint(columnNames={"name", "company_id", "global"}, name="UC_name_companyId_global")})
@Entity
@Audited
public class AccessLevel implements Serializable, GlobalEntityInstance {

private static final long serialVersionUID = -7215569721971710808L;

  @Size(min = 2)
  @Column(nullable = false)
  private String name;

  @ManyToOne(optional = false)
  private Company company;

  @Column
  private boolean global = false;

  @Column(nullable = false)
  private GeneralStatus status;
}

The company attribute is mapped to column company_id . company属性映射到列company_id

I've created a test case to test that when an Access Level is added with the same 'name', 'company' and 'global' value a DataIntegrityViolationException is thrown. 我创建了一个测试用例,以测试当使用相同的“名称”,“公司”和“全局”值添加访问级别时,将引发DataIntegrityViolationException The excetion is being thrown, my questions is about the message: 兴奋被抛出了,我的问题是关于消息的:

ohengine.jdbc.spi.SqlExceptionHelper : Duplicate entry 'Temp Level-1-\\x00' for key 'UC_name_companyId_global'

What in the heck is '\\x00' (or '\\x01' if true is saved) and why does the SqlExceptionHelper map/resolve a boolean value to it? “ \\ x00”(如果保存为true则为“ \\ x01”)到底是什么?为什么SqlExceptionHelper会为其映射/解析一个布尔值? Shouldnt the Duplicate entry key be 'Temp Level-1-false'? 重复输入键是否应该为“ Temp Level-1-false”?

Thanks in advance, Grant 预先感谢,格兰特

UPDATE: 更新:

Im currently using MySQl 5.6 我目前正在使用MySQl 5.6

\\x00 is hex 0 , and \\x01 is hex 1 . \\x00为十六进制0\\x01为十六进制1 Commonly (but not always) used values for false and true . 通常(但并非总是)使用falsetrue值。 MySQL for example stores boolean columns as BIT(1) , so it's working with 0/1 internally instead of true/false . 例如,MySQL将布尔列存储为BIT(1) ,因此它在内部使用0/1代替true/false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 这个'\\ x00 \\ x00 \\ x00 \\ x05'的编码是什么? - What encoding is this '\x00\x00\x00\x05'? 字符串作为\\ x03 \\ x00 \\ x00 \\ x00到整数 - String as \x03\x00\x00\x00 to integer HBase java 错误 - 预期 HEADER=HBas 但收到 HEADER=\x00\x00\x01\x0B - HBase java error - Expected HEADER=HBas but received HEADER=\x00\x00\x01\x0B Java 使用 AsynchronousSocketChannel 将空字节 (\\x00) 作为 1 个字符发送 - Java send nullbyte (\x00) as 1 character using AsynchronousSocketChannel 在向Accumulo写入文本时尾随空(\\ x00)字符 - Trailing null (\x00) characters when writing text to Accumulo 使用redis进行Spring引导缓存,key有\\xac\\xed\\x00\\x05t\\x00\\x06 - Spring boot caching with redis,key have \xac\xed\x00\x05t\x00\x06 java.sql.SQLException:不正确的字符串值:'\xAC\xED\x00\x05sr...' - java.sql.SQLException: Incorrect string value: '\xAC\xED\x00\x05sr...' 无法将字符串 '\xAC\xED\x00\x05~r...' 从二进制转换为 utf8mb3 - Cannot convert string '\xAC\xED\x00\x05~r...' from binary to utf8mb3 Hibernate 数据截断:不正确的 integer 值:'\xAC\xED\x00\x05sr\x00& 尝试保存 OneToMany 关系时 - Hibernate data truncation: Incorrect integer value: '\xAC\xED\x00\x05sr\x00& when trying to save a OneToMany Relation 为什么将“0000:00:00 00:00:00”解析为日期返回-0001-11-28T00:00:00Z? - Why does parsing “0000:00:00 00:00:00” into a Date return -0001-11-28T00:00:00Z?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM