2
我使用Play Framework 2.0(Java),但在全局实现一个简单的InitialData后,我有一些问题。 我使用PersistenceException当尝试添加模型Globals.InitialData后
我有2种型号:
- 用户(如电子邮件ID)
- SomeModel(长ID作为ID)
而且SomeModel有一个字段,如:
@ManyToOne
public User user;
所以在和有一个用户有很多SomeModels连接到它。
在我InitialData我将用户添加到测试出头:[email protected]。
所以,如果我尝试将SomeModel加入到本次测试的用户,我没有问题,即使我尝试添加一个以上。
当我加入SomeModel(让我们称之为一个TestModel)在我认为没有问题的InitialData,因为一切都在这个TestModel运行。但是,就在刚才,我看到,如果我尝试新的SomeModel添加到测试用户,我得到这个问题:
[PersistenceException: ERROR executing DML bindLog[] error[Unique index or primary key violation: "PRIMARY_KEY_D ON PUBLIC.SOME_MODEL(ID)"; SQL statement:\n insert into some_model (id, name, description, user_email) values (?,?,?,?) [23505-158]]]
这是我InitialData文件:
# Users
users:
- !!models.User
email: [email protected]
name: Test test
password: test
# SomeModels
somemodels:
- !!models.FuzzySystem
id: 1
name: test
description: test
user: !!models.User
email: [email protected]
我丢失此=(