Olá amigos estou fazendo uma migração de um sistema legado, mas está aparecendo este erro:
10:55:34.901 DEBUG org.hibernate.SQL: alter table ascensao add constraint FKmwiw2hrqw1ssxsrj8pnr6cou0 foreign key (idorgao) references cargo
10:55:34.933 WARN org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl: GenerationTarget encountered exception accepting command : Unable to execute command [alter table ascensao add constraint FKmwiw2hrqw1ssxsrj8pnr6cou0 foreign key (idorgao) references cargo]
org.hibernate.tool.schema.spi.CommandAcceptanceException: Unable to execute command [alter table ascensao add constraint FKmwiw2hrqw1ssxsrj8pnr6cou0 foreign key (idorgao) references cargo]
tenho as tabelas funcionario, cargo, orgao e ascensao:
table ascensao
@ManyToOne
@JoinColumn(name = "idfuncionario")
private Funcionario funcionario;
@ManyToOne
@JoinColumn(name = "idcargo")
private Cargo cargo;
@ManyToOne
@JoinColumn(name = "idorgao")
private Orgao orgao;
table cargo
@OneToMany(mappedBy = "cargo")
private List<Funcionario> funcionarios;
@OneToMany(mappedBy = "cargo")
private List<Ascensao> ascensoes;
table orgao
@OneToMany(mappedBy = "orgao")
private List<Funcionario> funcionarios;
@OneToMany(mappedBy = "orgao")
private List<Ascensao> ascensoes;
Estrutura da tabela
CREATE TABLE public.ascensao (
id integer NOT NULL DEFAULT nextval(‘ascensao_id_seq’::regclass),
excluido boolean DEFAULT false,
datacadastro timestamp without time zone,
isnovocadastro boolean,
matricula character varying(10),
tabela character varying(2),
dataocorrencia timestamp without time zone,
item character varying(6),
observacao character varying(255),
documento character varying(20),
dataret timestamp without time zone,
idcargo integer,
idorgao integer,
idfuncao integer,
idnivel integer,
idfuncionario integer,
idusuario integer,
dtret timestamp without time zone,
obs character varying(30),
CONSTRAINT rhascensao_pkey PRIMARY KEY (id),
CONSTRAINT fk2ighy4hili7b0rcq5hm71lk45 FOREIGN KEY (idcargo)
REFERENCES public.cargo (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk2ovsfioio3c8ml7aadfs5nr6u FOREIGN KEY (idfuncionario)
REFERENCES public.funcionario (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT rhascensao_usuario_fk FOREIGN KEY (idusuario)
REFERENCES public.usuario (codigo) MATCH FULL
ON UPDATE CASCADE ON DELETE SET NULL,
CONSTRAINT rhfuncionario_ascencao_fk FOREIGN KEY (idfuncionario)
REFERENCES public.funcionario (id) MATCH FULL
ON UPDATE CASCADE ON DELETE SET NULL
)
na tabela ascensao quando eu coloco o mapeamento de orgao aparece o erro.
Java, Spring, Hibernate, PostgreSQL
Alguém poderia ajudar?
Muito obrigado
Silvio Guedes