Hibernate created the table in existing database for jobLifeTime entity, but it given to first record auto generated code started with 8781, instead of 0. This table have foreign key to other object (scraperTask), that stored in DB right before jobLifeTime entity object, and hibernate given a code 8780 to scraperTask record (this clear because table with scraperTask already have some records).

Why hibernate use increment count for jobLifeTime.code from scraperTask.code?

**Update**
*Looks like Hibernate or PostgreSQL use one number sequence for both tables primary keys. It this right behavior?*

Here java classes and screenshot from database table:

[![jobLifeTime table - job_chron_stg](https://i.stack.imgur.com/H2Rue.png)](https://i.stack.imgur.com/H2Rue.png)

```
@Entity
@Table(name="job_chron_stg", indexes = {  @Index(name = "job_life_time_code_hidx", columnList = "code"),
        @Index(name = "job_life_time_job_id_hidx", columnList = "job_id")})
public class JobLifeTime {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)   
    private Long code;
    @Column(name="job_id", length=24)
    private String targetJobCode;
    @ManyToOne()
    private ScraperTask scraperTask;
    @Column(name="salary_low")
    private Integer salaryMin;
    @Column(name="salary_high")
    private Integer salaryMax;
    @Column(name="scrape_timestamp")
    private Date scrapeTimestamp;
    @Column(name="remove_timestamp")
    private Date removeTimestamp;

    public JobLifeTime(){}

    public JobLifeTime(Element node, ScraperTask scraperTask){
        targetJobCode = node.attr("data-jk");
        this.scraperTask = scraperTask;
        salaryMin = scraperTask.getSalaryMin();
        salaryMax = scraperTask.getSalaryMax();
        scrapeTimestamp = new Date();       
    }
//getters-setters
}

```

scraperTask class

```
@Entity
@Table(indexes = { @Index(name = "scraper_task_code_hidx", columnList = "code"),
        @Index(name = "task_start_at_hidx", columnList = "task_start_at")})
public class ScraperTask {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long code;
    @Column(name="task_start_at")
    private Date taskStartAt;
    private Date taskCompleteAt;
    private String description;
    @Transient
    private Integer salaryMin;
    @Transient
    private Integer salaryMax;
    //@Transient
    private Integer websiteJobsNumber;
    @Transient
    private String firstResponse;
    //@Transient
    //private Integer processedNodes;
    //@Transient
    private Boolean doneSuccessfully;
    @Transient
    private List<JobLifeTime> scrapedJobLifeTimeList;
    @Transient
    private List<Job> scrapedJobList;
    @Transient
    private KeywordsEntity keywordsEntity;
    @Transient
    private String category;

    protected ScraperTask(){
    }

    public ScraperTask(String uriString, Integer salaryMin, Integer salaryMax){
        description = uriString;
        taskStartAt = new Date();
        this.salaryMin = salaryMin;
        this.salaryMax = salaryMax;
        websiteJobsNumber=0;
        //processedNodes = 0;
        doneSuccessfully = false;
        scrapedJobLifeTimeList = new LinkedList<JobLifeTime>();
        scrapedJobList = new LinkedList<Job>();
    }
//getters-setters
}

```