[英]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
. 通常(但并非总是)使用
false
和true
值。 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.