'How to make new generated Entity ignore primary keys of existing one?

I'm developing crm system for car battery store and i faced an unpleasent error during testing. Using repesitory, every time i start a project i run several queries to fill up my PostGreSQL database, example:

@Modifying
@Transactional
@Query(nativeQuery = true, value = "insert into applicability values " +
        "(1,current_timestamp, 'Легковые автомабили', current_timestamp)," +
        "(2,current_timestamp, 'Грузовые автомабили', current_timestamp)," +
        "(3,current_timestamp, 'Мотоциклы', current_timestamp)," +
        "(4,current_timestamp, 'Спецтехника', current_timestamp) on conflict do nothing ")
void createApplicability();

But everytime, when i try to add new Entity into applicability table, i recieve a messages that says: "ERROR: Duplicate key value violates "applicability_pkey" unique constraint". I assume, that new generated entity sets its own id to 1 when getting generated and that is why i'm getting an error. But after 4 tries (that is equal to number if all id's in my table) i can finnally add new entity to the database with id 5.

Any suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source