Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring JPA OneToMany儿童_Spring_Jpa_Spring Boot - Fatal编程技术网

Spring JPA OneToMany儿童

Spring JPA OneToMany儿童,spring,jpa,spring-boot,Spring,Jpa,Spring Boot,我用Spring Boot JPA,如何坚持孩子与一夫一妻的关系? 在创建父实体时,子实体似乎不会自动持久化 其他人的关系很好,为什么 注册实体: @Entity @Table(name="Registration") public class Registration implements Serializable { @Id @GeneratedValue(generator = "uuid") @GenericGenerator(name="uuid", strat

我用Spring Boot JPA,如何坚持孩子与一夫一妻的关系? 在创建父实体时,子实体似乎不会自动持久化

其他人的关系很好,为什么

注册实体:

@Entity
@Table(name="Registration")
public class Registration implements Serializable {
    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name="uuid", strategy = "uuid2")
    @Column(columnDefinition = "BINARY(16)")
    private UUID uuid;

    @OneToMany(mappedBy ="registration", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinColumn(name="registration", nullable = false)
    private List<Payment> payment;

    private DateTime created;
    private DateTime updated;
}
尝试创建注册时记录:

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:列“created”不能为null


不清楚它抱怨哪个“创建”列为空。您在注册和付款中都有“已创建”的财产。在任何一种情况下,如果您的数据库表不接受空值,则该列似乎没有被设置在某个位置null@Mezoo看起来您是从一些JSON内容填充实体。您需要为子项的
created
字段设置一些值,或者使
Payment
表允许
created
列为空值。
@Entity
@Table(name="Payment")
public class Payment {
    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name="uuid", strategy = "uuid2")
    @Column(columnDefinition = "BINARY(16)")
    private UUID uuid;

    /* @ManyToOne(targetEntity=Registration.class)
    @JoinColumn(name="registration")
    private Registration registration; */

    private DateTime created;
    private DateTime updated;
}