Mam java Maven Web Application, odwołuję się do tabeli o poniższej definicji.
Definicja tabeli w bazie Oracle 12
CREATE TABLE "HURT"."DOSTAWCY"
(
"ID_DOSTAWCY" NUMBER GENERATED BY DEFAULT AS IDENTITY (
START WITH 1) NOT NULL PRIMARY KEY,
"NR_DOSTAWCY" NUMBER(*,0) NOT NULL,
"NAZWA_DOSTAWCY" VARCHAR2(30 BYTE) NOT NULL,
...)
otrzymywałem błędy przy deklaracji ID_DOSTAWCY w pliku encji tak zapisanym
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@NotNull
@Column(name = "ID_DOSTAWCY")
znalazłem artykuł który opisuje ten problem, wynika on ze stosowania NUMBER GENERATED BY DEFAULT AS IDENTITY nowego rozwiązania w Oracle Database
https://dnikiforov.wordpress.com/2015/02/14/oracle-12c-identity-and-popular-orms/
w tym artykule opisano tę sytuację i zaproponowano jako rozwiązanie dodanie adnotacji @ReturnInsert(returnOnly=true),
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ReturnInsert(returnOnly=true)
@Basic(optional = false)
@Column(name = "ID_DOSTAWCY")
po jej dodaniu w definicji encji Dostawcy, pojawa się błąd, w trakcie uruchomienia aplikacji ( w NetBeans ) na serwerze GlassFish 4.1
Exception [EclipseLink-191] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: ReturningPolicy contains field, [ID_DOSTAWCY] which is not supported: it is either sequence field, or class type indicator, or used for locking.
Descriptor: RelationalDescriptor(Encje.Dostawcy --> [DatabaseTable(DOSTAWCY)])
poniżej pełniejszy opis
Severe: Exception while deploying the app [HurtowniaWebAplikacja] : Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [com.mycompany_HurtowniaWebAplikacja_war_1.0-SNAPSHOTPU] failed. Close all factories for this PersistenceUnit.
Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
---------------------------------------------------------
Exception [EclipseLink-191] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: ReturningPolicy contains field, [ID_DOSTAWCY] which is not supported: it is either sequence field, or class type indicator, or used for locking.
Descriptor: RelationalDescriptor(Encje.Dostawcy --> [DatabaseTable(DOSTAWCY)])
Exception [EclipseLink-191] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: ReturningPolicy contains field, [ID_DOSTAWCY] which is not supported: it is either sequence field, or class type indicator, or used for locking.
Descriptor: RelationalDescriptor(Encje.Dostawcy --> [DatabaseTable(DOSTAWCY)])
Runtime Exceptions:
---------------------------------------------------------
jak rozwiązać tę sytuację