- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在数据库中:有一个字段的类型是TINYINT(1),默认值为0。在Model中它被定义为TINYINT(1) DEFAULT 0。但是它给出了如下错误:
错误
[jar:file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/NetaCommerceFrameworkAdmin/WEB-INF/lib/NetaCommerceFramework-0.0.1-SNAPSHOT.jar!/com/netasoft/commerce/framework/lang/dao/LangDaoImpl.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type
[org.hibernate.SessionFactory]: :Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/admin-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Wrong column type in kaft.nc_alert_log for column alerted. Found: bit, expected: TINYINT(1) DEFAULT 0; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/admin-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Wrong column type in kaft.nc_alert_log for column alerted. Found: bit, expected: TINYINT(1) DEFAULT 0
模型定义
@Column(name="alerted", columnDefinition = "TINYINT(1) DEFAULT 0")
private int alerted;
public int getAlerted() {
return alerted;
}
public void setAlerted(int alerted) {
this.alerted = alerted;
}
数据库属性
hibernate.hbm2ddl.auto=validate
#hibernate.hbm2ddl.auto=create-drop
hibernate.hbm2ddl.import_files=/import_standard.sql
hibernate.show_sql=false
hibernate.format_sql=true
hibernate.generate_statistics=false
hibernate.use_sql_comments=true
hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory
hibernate.cache.use_query_cache=true
hibernate.cache.region.factory_class=net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
hibernate.cache.use_second_level_cache=true
#-------------------------------------------------------------------------------
# MySQL Settings
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/xxx?autoReconnect=true
jdbc.username=xxx
jdbc.password=xxx
# Property that determines which Hibernate dialect / MySQL5Dialect || MySQLDialect
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
方言版本:
2013-01-17 08:45:36,920 INFO [org.hibernate.cfg.SettingsFactory] - Database ->
name : MySQL
version : 5.0.96-community-nt
major : 5
minor : 0
2013-01-17 08:45:36,921 INFO [org.hibernate.cfg.SettingsFactory] - Driver ->
name : MySQL-AB JDBC Driver
version : mysql-connector-java-5.1.12 ( Revision: ${bzr.revision-id} )
major : 5
minor : 1
它也在服务器和另一台计算机上运行。但是,在我的计算机和只是为了尝试而安装的新计算机中,它给出了相同的错误。我在谷歌上搜索了几天,无法弄清楚是什么原因导致了这个问题。尝试在模型中使用 boolean columnDefinition 并更改 MySqlDialect 定义,但没有任何变化。甚至错误消息都是一样的。
最佳答案
使用 BIT 作为列定义
这对我有用:
@Column(name = "my_field",columnDefinition = "BIT")
private int myField;
关于Spring 和 Hibernate,找到位,预期为 TINYINT(1) DEFAULT 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14381749/
这个问题在这里已经有了答案: 关闭10年前. Possible Duplicate: MySql: Tinyint (2) vs tinyint(1) - Which difference? 有什么区
我知道 mysql 中的 bool 值是 tinyint (1)。 今天我看到一个表格,其中定义了一个整数,如 tinyint(2),以及其他如 int(4)、int(6) ... integer 和
我需要在 1 个表中存储 5 个 boolean 值。每个值都可以存储为 tinyint(4)。所以,有 5 个 tinyint(4)。我正在考虑将 5 个 boolean 值放入一个 tinyint
在 Ruby on Rails 中,迁移中的以下代码在 MySQL 中创建了 tinyint(4) 类型的列: create_table :great_table do |t| t.integ
我想将 mysql 列从我用作 bool 值的tinyint(1) 转换为时间戳,但是我想通过在 true 时将日期插入到行中来保留现有数据。 那么我可以在考虑现有数据的同时更改表列吗? 我可以通过添
我正在尝试使用 Dapper 将数据库从 MySQL 迁移到 SQLServer。 除了 TinyInt 字段之外,几乎一切都很好。 无论我在 C# 代码中指定什么类型,Dapper 都会系统地抛出异
MySQL在什么情况下会将类型转换为TINYINT?我知道 mysql DDL 中的 BOOL 或 BOOLEAN 类型将自动转换为 TINYINT(1) for for true or false。
以下查询是否是转换字段数据类型的可接受方式? UPDATE INFORMATION_SCHEMA.COLUMNS SET `COLUMNS`.`DATA_TYPE` = 'tinyint' WHERE
我只是想知道。是否有可能在 Fluent API 或任何东西中将 Enum 类型映射为 tinyint? 比如说, public enum PaperType { Rough=1, Smoot
我尝试写入 t=t|128 但出现了超出范围的错误。我怀疑 tinyint 已签名。 但是http://dev.mysql.com/doc/refman/5.5/en/numeric-types.ht
我有一个包含五个 tinyint 列的表。 如果我查询一行,我会得到这样的结果: select flag1, flag2, flag3, flag4, flag5 from mytable where
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
我正在尝试将 tinyint 字段的值设置为 1、2 或 3,但未设置。我是 mySQL 的新手,所以我可能在某个地方犯了错误,但我看不到它。 我调用了该函数,并且正在设置所有其他字段,只是不是 ti
我对 MySQL Documentation 有点困惑满足各个领域的存储需求。我目前正在重新设计数据库,并且我看到 TINYINT(4) 作为它们的数据类型。以前我从未考虑过这一点,但这是否需要一个字
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
我这辈子都无法让 php 更新 mysql 中的 schdl 字段。它将更新测试查询中除 schdl 之外的所有其他字段。 schdl 值当前设置为 1,我正在尝试将其设置为 0。 schdl 字段的
我正在执行一个 select 语句,试图查找列 inactive 未设置为 1 的数据,但结果始终为 Empty Set。为什么会这样? mysql> select id, time, num, i
在 MySQL 数据库中,我有一个包含用户地址的表: CREATE TABLE `user_address` ( `id` INT(10) NOT NULL AUTO_INCREMENT,
我想更新状态值 -tinyint(1)- 以激活和停用用户。每当我尝试更新时,我都会收到下面设置为“助理更新失败”的消息。任何帮助都很感激。谢谢 if (empty($errors)) { // Pe
我有一个用状态标志定义的 mysql 表(它是一个 tinyint(1))。但是,当我尝试检查该值是真还是假时,我似乎得出了错误的结果。也就是说,它不会将该值视为合法的 true 或值,而是测试它是否
我是一名优秀的程序员,十分优秀!