Cześć,
Zmagam się z problemem dodania danych do bazy danych.
Projekt Spring, Hibernate, Oracle XE.
Mogę dodać dane do bazy jeśli sam określę numer id czyli używając konstruktora:
public Company(Integer id_Company, String name) {
this.id_Company = id_Company;
this.name = name;
Jeśli chcę użyć
@GeneratedValue(strategy = GenerationType.AUTO)
Konsola wyrzuca błąd:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.6.RELEASE)
2020-05-03 18:06:44.171 INFO 8812 --- [ main] pl.kos.EmpSys.App : Starting App on DESKTOP-F82EDTF with PID 8812 (C:\Users\PC KOMPUTER\IdeaProjects\EmpSys\target\classes started by PC KOMPUTER in C:\Users\PC KOMPUTER\IdeaProjects\EmpSys)
2020-05-03 18:06:44.173 INFO 8812 --- [ main] pl.kosk.EmpSys.App : No active profile set, falling back to default profiles: default
2020-05-03 18:06:44.505 INFO 8812 --- [ main] pl.kos.EmpSys.App : Started App in 0.544 seconds (JVM running for 0.792)
2020-05-03 18:06:44.572 INFO 8812 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-05-03 18:06:44.821 INFO 8812 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-05-03 18:06:44.938 WARN 8812 --- [ main] org.hibernate.orm.connections.pooling : HHH10001002: Using Hibernate built-in connection pool (not for production use!)
2020-05-03 18:06:44.996 INFO 8812 --- [ main] org.hibernate.orm.connections.pooling : HHH10001005: using driver [oracle.jdbc.OracleDriver] at URL [jdbc:oracle:thin:@localhost:1521:XE]
2020-05-03 18:06:44.996 INFO 8812 --- [ main] org.hibernate.orm.connections.pooling : HHH10001001: Connection properties: {password=****, user=bartek}
2020-05-03 18:06:44.997 INFO 8812 --- [ main] org.hibernate.orm.connections.pooling : HHH10001003: Autocommit mode: false
2020-05-03 18:06:44.998 INFO 8812 --- [ main] .c.i.DriverManagerConnectionProviderImpl : HHH000115: Hibernate connection pool size: 2 (min=1)
2020-05-03 18:06:45.194 INFO 8812 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.Oracle8iDialect
2020-05-03 18:06:45.398 WARN 8812 --- [ main] org.hibernate.orm.deprecation : HHH90000014: Found use of deprecated [org.hibernate.id.SequenceGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead. See Hibernate Domain Model Mapping Guide for details.
Hibernate: select hibernate_sequence.nextval from dual
**2020-05-03 18:06:45.706 WARN 8812 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 2289, SQLState: 42000
2020-05-03 18:06:45.706 ERROR 8812 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : ORA-02289: sekwencja nie istnieje**
Znalazłem taki oto artykuł ale żadne rozwiązanie z niego nie pomaga: https://www.it-swarm.dev/pl/java/sekwencja-hibernacji-nie-istnieje/1055052639/
Może miał ktoś z Was podobny problem i wie jak rozwiązać problem z auto numeracją klucza tabeli?