<commit_before>package org.fjorum.model.entity;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "category")
public class Category {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    @Column(name = "cat_name")
    private String name;
    @Column(name = "order_id")
    private int orderId;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", orphanRemoval = true)
    @OrderColumn(name = "order_id")
    private List<Category> children = new ArrayList<>();

    @ManyToOne
    @JoinColumn(name = "parent_id")
    protected Category parent;

    protected Category() {
    }

    public Category(String name, Category parent) {
        setName(name);
        List<Category> children = parent.getChildren();
        setOrderId(children.isEmpty() ? 0 : children.get(children.size()-1).orderId + 1);
        setParent(parent);
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {<commit_msg>fixed Category constructor which threw a NPE when initializing an empty DB<commit_after>package org.fjorum.model.entity;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "category")
public class Category {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    @Column(name = "cat_name")
    private String name;
    @Column(name = "order_id")
    private int orderId;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", orphanRemoval = true)
    @OrderColumn(name = "order_id")
    private List<Category> children = new ArrayList<>();

    @ManyToOne
    @JoinColumn(name = "parent_id")
    protected Category parent;

    protected Category() {
    }

    public Category(String name, Category parent) {
        setName(name);
        if (parent == null) {
            setOrderId(0);
        } else {
            List<Category> children = parent.getChildren();
            setOrderId(children.isEmpty() ? 0 : children.get(children.size() - 1).orderId + 1);
            setParent(parent);
        }
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
{'fraction_non_alphanumeric': 0.12083152880034648, 'fraction_numerical': 0.0030316154179298397, 'mean_word_length': 3.0384615384615383, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1883398', 'n_tokens_mistral': 702, 'n_tokens_neox': 684, 'n_words': 173}