- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个非常简单的对象结构,它给我一个我无法解决的错误。做了很多搜索,我认为这一定是一个非常常见的用例,所以不确定问题是什么。我有这三个类:
@Entity
public class Widget {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int idd;
private Date date;
private String type;
private int ownerId;
@OneToOne(cascade = CascadeType.ALL)
private Rating rating;
@OneToMany(cascade = CascadeType.ALL)
private List<Tag> tagList;
}
@Entity
public class Rating {
public enum ChartType {RADAR, BAR, LINE, STAR};
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int ratingId;
private String name;
@Enumerated(EnumType.STRING)
private ChartType chartType;
private double normalizedValue;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
private List<RatingComponent> componentList = new ArrayList<>();
public Rating() {
buildNormalizedValue();
}
}
@Entity
public class RatingComponent {
@Id
@GeneratedValue()
private int compId;
private String name;
private double value;
private double maxValue;
}
在 DAO 中保存时出现我不太理解的错误,例如
2018-07-23 11:43:07,208 WARN o.h.t.s.i.ExceptionHandlerLoggedImpl [main] GenerationTarget encountered exception accepting command :
Error executing DDL "alter table Rating_RatingComponent drop foreign key FKaudjguwlo1i8tm2jgli5bbnq6" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table Rating_RatingComponent drop foreign key FKaudjguwlo1i8tm2jgli5bbnq6" via JDBC Statement
再往下
2018-07-23 11:43:07,644 WARN o.h.t.s.i.ExceptionHandlerLoggedImpl [main] GenerationTarget encountered exception accepting command : Error executing DDL "create table RatingComponent (compId integer not null, maxValue double precision not null, name varchar(255), value double precision not null, primary key (compId)) engine=InnoDB" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table RatingComponent (compId integer not null, maxValue double precision not null, name varchar(255), value double precision not null, primary key (compId)) engine=InnoDB" via JDBC Statement
我的配置中有这些属性
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
我认为我已经非常仔细地阅读了文档,并且认为这是一个非常直接的对象设计......关于如何解决的任何想法,以及我应该更仔细地研究文档中的什么地方以了解根本原因?
谢谢!
最佳答案
我使用了 SQL 保留字 'order'
作为实体名称,因此我遇到了类似的错误。重命名它为我解决了它。看你的实体名,有没有用保留字?
关于java - hibernate 外键问题: Error executing DDL "alter table...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51482774/
我知道这不是什么大问题,但还是让我觉得很痒。 我有一个 SQL Server 2005 脚本来创建新的数据表、约束、更改一些表以添加列、更改过程以将表更改考虑在内等。 一切正常,直到脚本遇到我的 AL
我需要一个包含三列的数据框:i、j(改变)和 k(j 的改变)。我有一个邻接矩阵(下面的示例)。从那里我可以获得一个图形对象并提取边缘列表。我如何操作数据以获得类似于下面的 WANT 数据框的输出?
假设我有这个 SQL 语句: ALTER TABLE dbo.[tbl] ALTER COLUMN col1 varchar(300) ALTER TABLE dbo.[tbl] ALTER COLU
我在表中有一列,因此它不再是 NVARCHAR(256),而是 NVARCHAR(MAX)。我知道执行此操作的命令 (ALTER TABLE ALTER COLUMN NVARCHAR(MAX))。我
我在表中有一列,因此它不再是 NVARCHAR(256),而是 NVARCHAR(MAX)。我知道执行此操作的命令 (ALTER TABLE ALTER COLUMN NVARCHAR(MAX))。我
假设我有这两个 ALTER TABLE: ALTER TABLE tableName ADD COLUMN colName INT(11) AFTER colName2 ALTER TABLE tab
我正在尝试扩展 IdentityUser 类。我添加了一个新类 ApplicationUser 并继承了 IdentityUser 类。迁移已成功添加,但在更新数据库时,出现错误“对象 'PK_Asp
我想将 sql server 2005 表中的列修改为 IDENTITY(1,1) 顺便说一句,该表是空的,要更改的列是主键。 该列也是另外两个表的外键。 谷歌搜索后我发现你不能使用Alter tab
这是我要实现的目标:我在列表中有四个按钮,每个按钮都有白色背景和独特的彩色边框。单击一个按钮时,其背景颜色将与其边框颜色相同。单击第二个按钮时,第一个按钮恢复正常,第二个按钮的背景填充第二个按钮的边框
我在 clickhouse 有一张 table ,比如“my_table”,它有复制品(my_table_rep1,...)。我需要添加一个列,类型为 float64,默认值 (-1)。 我该怎么做?
alter FUNCTION [Kuri].[fnGetAge](@kuri_cust_Id int,@amt decimal) RETURNS SMALLINT AS BEGIN D
我试图确保当我 mysqldump 数据库时约束在执行以下查询后按数字顺序排列。当我在没有 AFTER 的情况下进行转储(这不起作用)时,它显示 phppos_sales_ibfk_3 作为第一个约束
我有两个表:cleanup 和 uniqueEntries。它们都有一个自动递增的id作为主键。 uniqueEntries 的表结构来自 cleanup,如下所示: $sql = "CREATE T
我有一个包含以下数据和结构的表: Date Analyst Start Time Stop Time 4/2/2018 Bill Smith 7:00
This question already has answers here: Error renaming a column in MySQL
是否可以更改表的多(复合)列键? 示例表: CREATE TABLE `test_abc` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `
我尝试执行 oracle alter session 查询以更改语言设置,但失败并出现错误“ORA-01036:非法变量名称/编号”。 preparedStatement = connection.p
我正在与一位客户合作,他希望大型数据库中的每个表的每条记录都有历史数据,并且为了美观,希望这些列位于每个表的末尾。例如: 表名 主键 数据列 历史专栏 所以我的问题是,是否有一个 SQL 命令可以将列
我正在尝试更改 SQL Server 2000 更新触发器,但它一直挂着、挂着、挂着。为什么会发生这种情况,我该怎么做才能解决这个问题?这是一个长触发器,这可能是为什么? 触发代码较长,简化如下: A
我正在将我的 mysql 数据库表从 id (auto) 更改为 uid。 ALTER TABLE companies DROP PRIMARY KEY; ALTER TABLE companies
我是一名优秀的程序员,十分优秀!