0

Por mas que pregunto a chatgpt no consigo que funcione. al hacer un find en persona me da un identificador no valido debido a la relacion. el problema esta en la relacion one to one con Exitus

Caused by: Error : 904, Position : 1717, SQL = select person0_.ID as ID1_27_0_, person0_.ACTION as ACTION2_27_0_, person0_.APPLICATION as APPLICATION20_27_0_, person0_.CREATION_DATE as CREATION_DATE3_27_0_, person0_.CREATION_USER as CREATION_USER4_27_0_, person0_.MODIFICATION_DATE as MODIFICATION_DATE5_27_0_, person0_.MODIFICATION_USER as MODIFICATION_USER6_27_0_, person0_.ACTIVE as ACTIVE7_27_0_, person0_.BIRTH_PLACE as BIRTH_PLACE8_27_0_, person0_.DATE_OF_BIRTH as DATE_OF_BIRTH9_27_0_, person0_.DOCUMENT_IDENTIFICATION as DOCUMENT_IDENTIFI10_27_0_, person0_.DOCUMENT_ID as DOCUMENT_ID21_27_0_, person0_.EXPIRATION_DATE_IDENTIFICATION as EXPIRATION_DATE_I11_27_0_, person0_.GENDER as GENDER12_27_0_, person0_.MARITAL_STATUS as MARITAL_STATUS13_27_0_, person0_.NAME as NAME14_27_0_, person0_.OBSERVATIONS as OBSERVATIONS15_27_0_, person0_.SEX as SEX16_27_0_, person0_.SOCIAL_SECURITY_NUMBER as SOCIAL_SECURITY_N17_27_0_, person0_.SURNAME1 as SURNAME18_27_0_, person0_.SURNAME2 as SURNAME19_27_0_, person0_.BIRTH_COUNTRY_ID as BIRTH_COUNTRY_ID22_27_0_, person0_.BIRTH_ISLAND as BIRTH_ISLAND23_27_0_, person0_.BIRTH_LOCALITY as BIRTH_LOCALITY24_27_0_, person0_.BIRTH_MUNICIPALITY as BIRTH_MUNICIPALIT25_27_0_, person0_.BIRTH_PROVINCE as BIRTH_PROVINCE26_27_0_, documentty1_.ID as ID1_6_1_, documentty1_.ACTION as ACTION2_6_1_, documentty1_.APPLICATION as APPLICATION10_6_1_, documentty1_.CREATION_DATE as CREATION_DATE3_6_1_, documentty1_.CREATION_USER as CREATION_USER4_6_1_, documentty1_.MODIFICATION_DATE as MODIFICATION_DATE5_6_1_, documentty1_.MODIFICATION_USER as MODIFICATION_USER6_6_1_, documentty1_.IS_ACTIVE as IS_ACTIVE7_6_1_, documentty1_.DESCRIPTION as DESCRIPTION8_6_1_, documentty1_.DOCUMENT_NAME as DOCUMENT_NAME9_6_1_, exitus2_.ID as ID1_7_2_, exitus2_.ACTION as ACTION2_7_2_, exitus2_.APPLICATION as APPLICATION11_7_2_, exitus2_.CREATION_DATE as CREATION_DATE3_7_2_, exitus2_.CREATION_USER as CREATION_USER4_7_2_, exitus2_.MODIFICATION_DATE as MODIFICATION_DATE5_7_2_, exitus2_.MODIFICATION_USER as MODIFICATION_USER6_7_2_, exitus2_.DATE_OF_DEATH as DATE_OF_DEATH7_7_2_, exitus2_.FORM_DATE as FORM_DATE8_7_2_, exitus2_.ORIGEN as ORIGEN9_7_2_, exitus2_.person as person12_7_2_, exitus2_.STATE as STATE10_7_2_ from RUP_PERSON person0_ inner join RUP_DOCUMENT_TYPE documentty1_ on person0_.DOCUMENT_ID=documentty1_.ID left outer join RUP_EXITUS exitus2_ on person0_.ID=exitus2_.person where person0_.ID=:1 , Original SQL = select person0_.ID as ID1_27_0_, person0_.ACTION as ACTION2_27_0_, person0_.APPLICATION as APPLICATION20_27_0_, person0_.CREATION_DATE as CREATION_DATE3_27_0_, person0_.CREATION_USER as CREATION_USER4_27_0_, person0_.MODIFICATION_DATE as MODIFICATION_DATE5_27_0_, person0_.MODIFICATION_USER as MODIFICATION_USER6_27_0_, person0_.ACTIVE as ACTIVE7_27_0_, person0_.BIRTH_PLACE as BIRTH_PLACE8_27_0_, person0_.DATE_OF_BIRTH as DATE_OF_BIRTH9_27_0_, person0_.DOCUMENT_IDENTIFICATION as DOCUMENT_IDENTIFI10_27_0_, person0_.DOCUMENT_ID as DOCUMENT_ID21_27_0_, person0_.EXPIRATION_DATE_IDENTIFICATION as EXPIRATION_DATE_I11_27_0_, person0_.GENDER as GENDER12_27_0_, person0_.MARITAL_STATUS as MARITAL_STATUS13_27_0_, person0_.NAME as NAME14_27_0_, person0_.OBSERVATIONS as OBSERVATIONS15_27_0_, person0_.SEX as SEX16_27_0_, person0_.SOCIAL_SECURITY_NUMBER as SOCIAL_SECURITY_N17_27_0_, person0_.SURNAME1 as SURNAME18_27_0_, person0_.SURNAME2 as SURNAME19_27_0_, person0_.BIRTH_COUNTRY_ID as BIRTH_COUNTRY_ID22_27_0_, person0_.BIRTH_ISLAND as BIRTH_ISLAND23_27_0_, person0_.BIRTH_LOCALITY as BIRTH_LOCALITY24_27_0_, person0_.BIRTH_MUNICIPALITY as BIRTH_MUNICIPALIT25_27_0_, person0_.BIRTH_PROVINCE as BIRTH_PROVINCE26_27_0_, documentty1_.ID as ID1_6_1_, documentty1_.ACTION as ACTION2_6_1_, documentty1_.APPLICATION as APPLICATION10_6_1_, documentty1_.CREATION_DATE as CREATION_DATE3_6_1_, documentty1_.CREATION_USER as CREATION_USER4_6_1_, documentty1_.MODIFICATION_DATE as MODIFICATION_DATE5_6_1_, documentty1_.MODIFICATION_USER as MODIFICATION_USER6_6_1_, documentty1_.IS_ACTIVE as IS_ACTIVE7_6_1_, documentty1_.DESCRIPTION as DESCRIPTION8_6_1_, documentty1_.DOCUMENT_NAME as DOCUMENT_NAME9_6_1_, exitus2_.ID as ID1_7_2_, exitus2_.ACTION as ACTION2_7_2_, exitus2_.APPLICATION as APPLICATION11_7_2_, exitus2_.CREATION_DATE as CREATION_DATE3_7_2_, exitus2_.CREATION_USER as CREATION_USER4_7_2_, exitus2_.MODIFICATION_DATE as MODIFICATION_DATE5_7_2_, exitus2_.MODIFICATION_USER as MODIFICATION_USER6_7_2_, exitus2_.DATE_OF_DEATH as DATE_OF_DEATH7_7_2_, exitus2_.FORM_DATE as FORM_DATE8_7_2_, exitus2_.ORIGEN as ORIGEN9_7_2_, exitus2_.person as person12_7_2_, exitus2_.STATE as STATE10_7_2_ from RUP_PERSON person0_ inner join RUP_DOCUMENT_TYPE documentty1_ on person0_.DOCUMENT_ID=documentty1_.ID left outer join RUP_EXITUS exitus2_ on person0_.ID=exitus2_.person where person0_.ID=?, Error Message = ORA-00904: "EXITUS2_"."ACTION": identificador no v�lido

estas son las clases person tiene mas cosas pero por abrevair solo pondre lo del common

public class Person extends CommonPerson {}

public class CommonPerson extends BaseEntity {

    private static final long serialVersionUID = 1L;
    /**
     * Name of person
     */
    @Column(name = "NAME", length = 50, nullable = false)
    @Size(max = 50)
    @NotNull
    private String name;

    /**
     * First surname of the person
     */
    @Column(name = "SURNAME1", length = 60, nullable = false)
    @Size(max = 60)
    @NotNull
    private String surname1;

    /**
     * Second surname of the person
     */
    @Column(name = "SURNAME2", length = 60)
    @Size(max = 60)
    private String surname2;

    /**
     * Date of birth of the person
     */
    @Column(name = "DATE_OF_BIRTH", nullable = false)
    private LocalDate dateOfBirth;

    /**
     * Sex, DD -> SEX
     */
    @Column(name = "SEX", length = 1)
    @Size(max = 1)
    private String sex;

    /**
     * If the person is active
     */
    @Column(name = "ACTIVE")
    private boolean active;

    /**
     * Marital status, DD -> MARITAL_STATUS
     */
    @Column(name = "MARITAL_STATUS", length = 80)
    @Size(max = 80)
    private String maritalStatus;

    /**
     * In disuse, replaced by table RUP_OBSERVATION
     */
    @Column(name = "OBSERVATIONS", length = 4000)
    @Size(max = 4000)
    private String observations;

    /**
     * Social security number
     */
    @Column(name = "SOCIAL_SECURITY_NUMBER", length = 13)
    @Size(max = 13)
    private String socialSecurityNumber;

    /**
     * Field for specifying the place of birth in case of foreign nationals
     */
    @Column(name = "BIRTH_PLACE", length = 500)
    @Size(max = 500)
    private String birthPlace;

    /**
     * Identification document of the person
     */
    @ManyToOne(targetEntity = DocumentType.class)
    @JoinColumn(name = "DOCUMENT_ID", nullable = false)
    private DocumentType documentType;

    /**
     * FK, type of identification document of the person
     */
    @Column(name = "DOCUMENT_IDENTIFICATION", length = 60, unique = true)
    @NotNull
    private String documentIdentification;
    
    @OneToOne(mappedBy = "person")
    private Exitus exitus;

    /**
     * Date of DNI´s expiration of the person
     */
    @Column(name = "EXPIRATION_DATE_IDENTIFICATION")
    private LocalDate expirationDateIdentification;

    @Column(name = "GENDER")
    @Min(value = 1, message = "Gender ID must be at least 1")
    @Max(value = 3, message = "Gender ID must be at most 3")
    private Long gender;
}

esta es la otra clase con la que hacer relacion 1 a 1

public class Exitus extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "exitusSeq")
    @Column(name = "ID", nullable = false)
    private long id;

    @Column(name = "STATE", nullable = false)
    private long state;

    @OneToOne
    @JoinColumn(name = "person", referencedColumnName = "ID", nullable = false)
    private Person person;

    @Column(name = "DATE_OF_DEATH", nullable = false)
    private LocalDate dateOfDeath;

    @Column(name = "FORM_DATE", updatable = false)
    private LocalDate formDate;

    @Column(name = "ORIGEN")
    private long origin;

    @OneToMany(mappedBy = "exitus")
    private List<HistoricalExitus> listHistotical;
}

el dll de exitus

--------------------------------------------------------
--  DDL for Table RUP_EXITUS
--------------------------------------------------------

  CREATE TABLE "RUPER"."RUP_EXITUS" 
   (    "ID" NUMBER, 
    "STATE" NUMBER, 
    "PERSON" NUMBER, 
    "DATE_OF_DEATH" DATE, 
    "FORM_DATE" DATE, 
    "ORIGEN" NUMBER, 
    "MODIFICATION_DATE" DATE DEFAULT SYSDATE, 
    "CREATION_USER" VARCHAR2(50 CHAR), 
    "CREATION_DATE" DATE DEFAULT SYSDATE, 
    "MODIFICATION_USER" VARCHAR2(50 CHAR), 
    "APPLICATION" VARCHAR2(50 BYTE)
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 
 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;

   COMMENT ON COLUMN "RUPER"."RUP_EXITUS"."MODIFICATION_DATE" IS 'Audit modification date (Auto)';
   COMMENT ON COLUMN "RUPER"."RUP_EXITUS"."CREATION_USER" IS 'Audit user creation (AUTO)';
   COMMENT ON COLUMN "RUPER"."RUP_EXITUS"."CREATION_DATE" IS 'Audit creation date (AUTO)';
   COMMENT ON COLUMN "RUPER"."RUP_EXITUS"."MODIFICATION_USER" IS 'Audit modification user (Auto)';
--------------------------------------------------------
--  DDL for Index RUP_EXISTUS_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "RUPER"."RUP_EXISTUS_PK" ON "RUPER"."RUP_EXITUS" ("ID") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  Constraints for Table RUP_EXITUS
--------------------------------------------------------

  ALTER TABLE "RUPER"."RUP_EXITUS" MODIFY ("ID" NOT NULL ENABLE);
  ALTER TABLE "RUPER"."RUP_EXITUS" ADD CONSTRAINT "RUP_EXITUS_PK" PRIMARY KEY ("ID")
  USING INDEX (CREATE UNIQUE INDEX "RUPER"."RUP_EXISTUS_PK" ON "RUPER"."RUP_EXITUS" ("ID") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" )  ENABLE;
  ALTER TABLE "RUPER"."RUP_EXITUS" MODIFY ("DATE_OF_DEATH" NOT NULL ENABLE);
  ALTER TABLE "RUPER"."RUP_EXITUS" MODIFY ("APPLICATION" NOT NULL ENABLE);
  ALTER TABLE "RUPER"."RUP_EXITUS" MODIFY ("STATE" NOT NULL ENABLE);
  ALTER TABLE "RUPER"."RUP_EXITUS" MODIFY ("CREATION_USER" NOT NULL ENABLE);
  ALTER TABLE "RUPER"."RUP_EXITUS" MODIFY ("CREATION_DATE" NOT NULL ENABLE);
--------------------------------------------------------
--  Ref Constraints for Table RUP_EXITUS
--------------------------------------------------------

  ALTER TABLE "RUPER"."RUP_EXITUS" ADD CONSTRAINT "RUP_EXITUS_PERSON_FK" FOREIGN KEY ("PERSON")
      REFERENCES "RUPER"."RUP_PERSON" ("ID") ENABLE;
  ALTER TABLE "RUPER"."RUP_EXITUS" ADD CONSTRAINT "RUP_EXITUS_APLICATION_FK" FOREIGN KEY ("APPLICATION")
      REFERENCES "RUPER"."RUP_APPLICATION" ("CODE") ENABLE;

y el de persona

--------------------------------------------------------
--  DDL for Table RUP_PERSON
--------------------------------------------------------

  CREATE TABLE "RUPER"."RUP_PERSON" 
   (    "ID" NUMBER(20,0), 
    "NAME" VARCHAR2(50 CHAR), 
    "SURNAME1" VARCHAR2(60 CHAR), 
    "SURNAME2" VARCHAR2(60 CHAR), 
    "DATE_OF_BIRTH" DATE, 
    "SEX" VARCHAR2(1 CHAR), 
    "CONTACT_LANGUAGE" VARCHAR2(5 CHAR), 
    "MODIFICATION_DATE" DATE DEFAULT SYSDATE, 
    "CREATION_USER" VARCHAR2(50 CHAR) DEFAULT user, 
    "SYSTEM_DEACTIVATION_DATE" DATE, 
    "BIRTH_COUNTRY_ID" NUMBER, 
    "BIRTH_PROVINCE" VARCHAR2(20 CHAR), 
    "BIRTH_ISLAND" VARCHAR2(20 CHAR), 
    "BIRTH_MUNICIPALITY" VARCHAR2(20 CHAR), 
    "PHONE_NUMBER1" VARCHAR2(15 CHAR), 
    "PHONE_NUMBER2" VARCHAR2(15 CHAR), 
    "MAIL" VARCHAR2(200 CHAR), 
    "ACTIVE" NUMBER(1,0), 
    "MARITAL_STATUS" VARCHAR2(80 BYTE), 
    "OBSERVATIONS" VARCHAR2(4000 BYTE), 
    "SOCIAL_SECURITY_NUMBER" VARCHAR2(13 CHAR), 
    "BIRTH_PLACE" VARCHAR2(500 CHAR), 
    "TSU_NUMBER" VARCHAR2(20 CHAR), 
    "TSA_NUMBER" VARCHAR2(80 BYTE), 
    "DEACTIVATION_REASON" NUMBER(3,0), 
    "UNDOCUMENTED" NUMBER(1,0) DEFAULT 0, 
    "DOCUMENT_ID" NUMBER, 
    "DOCUMENT_IDENTIFICATION" VARCHAR2(60 BYTE), 
    "CREATION_DATE" DATE DEFAULT SYSDATE, 
    "MODIFICATION_USER" VARCHAR2(50 CHAR), 
    "ACTION" VARCHAR2(6 BYTE) DEFAULT 'CREATE', 
    "APPLICATION" VARCHAR2(10 BYTE) DEFAULT NULL, 
    "DATE_OF_DEATH" DATE, 
    "EXITUS" NUMBER(1,0), 
    "EXPIRATION_DATE_IDENTIFICATION" DATE, 
    "GENDER" NUMBER, 
    "BIRTH_LOCALITY" VARCHAR2(20 BYTE)
   ) SEGMENT CREATION IMMEDIATE 
--------------------------------------------------------
--  Ref Constraints for Table RUP_PERSON
--------------------------------------------------------

  ALTER TABLE "RUPER"."RUP_PERSON" ADD CONSTRAINT "RUP_PERSON_APPLICATION_FK" FOREIGN KEY ("APPLICATION")
      REFERENCES "RUPER"."RUP_APPLICATION" ("CODE") ENABLE;
  ALTER TABLE "RUPER"."RUP_PERSON" ADD CONSTRAINT "RUP_PERSON_BIRTH_PROVINCE_FK" FOREIGN KEY ("BIRTH_PROVINCE")
      REFERENCES "RUPER"."RUP_PROVINCE" ("CODE") ENABLE;
  ALTER TABLE "RUPER"."RUP_PERSON" ADD CONSTRAINT "RUP_PERSON_BIRTH_MUNICIPALITY_FK" FOREIGN KEY ("BIRTH_MUNICIPALITY")
      REFERENCES "RUPER"."RUP_MUNICIPALITY" ("ID") ENABLE;
  ALTER TABLE "RUPER"."RUP_PERSON" ADD CONSTRAINT "RUP_PERSON_BIRTH_COUNTRY_FK" FOREIGN KEY ("BIRTH_COUNTRY_ID")
      REFERENCES "RUPER"."RUP_COUNTRY" ("ID") ENABLE;
  ALTER TABLE "RUPER"."RUP_PERSON" ADD CONSTRAINT "RUP_PERSON_DOCUMENT_TYPE_FK" FOREIGN KEY ("DOCUMENT_ID")
      REFERENCES "RUPER"."RUP_DOCUMENT_TYPE" ("ID") ENABLE;
  ALTER TABLE "RUPER"."RUP_PERSON" ADD CONSTRAINT "RUP_PERSON_LOCALITY_FK" FOREIGN KEY ("BIRTH_LOCALITY")
      REFERENCES "RUPER"."RUP_LOCALITY" ("ID") ENABLE;
  ALTER TABLE "RUPER"."RUP_PERSON" ADD CONSTRAINT "RUP_PERSON_EXITUS_FK" FOREIGN KEY ("EXITUS")
      REFERENCES "RUPER"."RUP_EXITUS" ("ID") ENABLE;

1 respuesta 1

2

Pues, primero que nada siempre hay que dirigirse al error.

Dentro del error que mandas, primero mandaste es el Caused by: Error : 904, Position : 1717, el cual indica donde ha ocurrido el error, pero no es el error como tal. El error está al final de ese segmento:

Error Message = ORA-00904: "EXITUS2_"."ACTION": identificador no v�lido

Si tomamos el error y su código, nos dirigimos a Google y buscamos: ORA-00904. Obtenemos lo siguiente en el primer link: https://docs.oracle.com/en/error-help/db/ora-00904/?r=23ai

Descripcion del error ORA-00904

Si no entendemos inglés, pues, preguntemosle a ChatGPT que nos quiere decir:

Causa: El identificador o nombre de columna ingresado no es válido.

Acción Asegúrese de lo siguiente:

1.- Ingrese un identificador o nombre de columna válido y verifique que no haya errores tipográficos en el identificador o nombre de columna. Un identificador válido debe comenzar con una letra, tener un máximo de 128 caracteres y consistir solo en caracteres alfanuméricos y los caracteres especiales $, _, y #. Si contiene otros caracteres, debe estar entre comillas dobles.
2.- No debe ser una palabra reservada a menos que esté entre comillas dobles.
3.- Si se usaron comillas dobles y mayúsculas y minúsculas mezcladas para un nombre de columna al crear la tabla, entonces las referencias a esa columna deben usar las mismas mayúsculas y comillas.

Entonces, que hay que hacer ahora ???

Revisar la estructura de la tabla RUP_EXITUS y confirmar que ACTION es el nombre correcto de la columna.

AL parecer te has equivocado, y has buscado ACTION dentro de RUP_EXITUS, cuando ACTION está dentro de RUP_PERSON.

De ser correcto, y tu ver todo bien, comparte una imagen de la tabla y sus columnas por favor. Edita la publicación y agregala alla.

2
  • 1
    MUCHAS gracias estaba obcecado en que era problema de la relacion y no vi que me faltaba un campo en la tabla que si estaba en la entidad
    – unknow
    Commented el 29 oct. a las 19:25
  • 1
    No pasa nada, siempre hay que revisar bien el error ;)
    – Excorpion
    Commented el 29 oct. a las 19:38

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.