EclipseLink - 不创建关系

EclipseLink - Not creating relationship

我不知道为什么没有在我的数据库中创建关系。我在 table 中有 7 个关系,其中 5 个关系工作正常,但 2(materialServico,unidadeMedida) 不会出现在数据库中(查看 CONSTRAINT REFERENCES)并且日志中没有任何内容。有人经历过吗?我将 eclipselink 2.5.1 与 spring 3.2.1.RELEASE 和 SqlServer 2012(也在 postgresql 中测试)一起使用。通常我使用 Hibernate 作为 ORM...

@JoinColumns({
    @JoinColumn(name = "COD_EMPRESA", referencedColumnName = "COD_EMPRESA", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "COD_FILIAL", referencedColumnName = "COD_FILIAL", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "COD_CONTA_CONTABIL", referencedColumnName = "COD_CONTA_CONTABIL", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "DATA_CONTA_CONTABIL", referencedColumnName = "DATA_CONTA_CONTABIL", nullable = true, insertable=false, updatable=false)})
@ManyToOne(optional = false)
private Conta conta = new Conta();

@JoinColumns({
    @JoinColumn(name = "COD_EMPRESA", referencedColumnName = "COD_EMPRESA", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "COD_FILIAL", referencedColumnName = "COD_FILIAL", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "COD_UNIDADE_MEDIDA", referencedColumnName = "COD_UNIDADE_MEDIDA", nullable = true, insertable=false, updatable=false)})
@ManyToOne(optional = false)
private UnidadeMedida unidadeMedida = new UnidadeMedida();

 @JoinColumns({
    @JoinColumn(name = "COD_EMPRESA", referencedColumnName = "COD_EMPRESA", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "COD_FILIAL", referencedColumnName = "COD_FILIAL", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "COD_NAT_OPERACAO", referencedColumnName = "COD_NAT_OPERACAO", nullable = true, insertable=false, updatable=false)})
@ManyToOne(optional = false)
private NaturezaOperacao naturezaOperacao = new NaturezaOperacao();

@JoinColumns({
    @JoinColumn(name = "COD_EMPRESA", referencedColumnName = "COD_EMPRESA", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "COD_FILIAL", referencedColumnName = "COD_FILIAL", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "CHAVE_NFE", referencedColumnName = "CHAVE_NFE", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "DATA_REF", referencedColumnName = "DATA_REF", nullable = true, insertable=false, updatable=false)})
@ManyToOne(optional = false)
private MestreNotaFiscal mestreNotaFiscal = new MestreNotaFiscal();

@JoinColumns({
    @JoinColumn(name = "COD_EMPRESA", referencedColumnName = "COD_EMPRESA", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "COD_FILIAL", referencedColumnName = "COD_FILIAL", nullable = true, insertable=false, updatable=false),
    @JoinColumn(name = "COD_ITEM", referencedColumnName = "COD_ITEM", nullable = true, insertable=false, updatable=false)})
@ManyToOne(optional = true)
private MaterialServico materialServico;

Sql 日志:它为 mestreNotaFiscal、filial、conta、naturezaOperacao、empresa 创建 FK。不要在日志中显示来自此 table 的更多 FK。

ALTER TABLE SYS033_ITENS_NFS ADD CONSTRAINT SYS033ITENSNFSDATA_REF FOREIGN KEY (DATA_REF, CHAVE_NFE, COD_FILIAL, COD_EMPRESA) REFERENCES SYS032_MESTRE_NFS (DATA_REF, CHAVE_NFE, COD_FILIAL, COD_EMPRESA)
ALTER TABLE SYS033_ITENS_NFS ADD CONSTRAINT SYS033ITENSNFSCDFILIAL FOREIGN KEY (COD_FILIAL, COD_EMPRESA) REFERENCES SYS001_FILIAIS (COD_FILIAL, COD_EMPRESA)
ALTER TABLE SYS033_ITENS_NFS ADD CONSTRAINT SYS033TNSNFSCDCNTCNTBL FOREIGN KEY (COD_CONTA_CONTABIL, COD_FILIAL, DATA_CONTA_CONTABIL, COD_EMPRESA) REFERENCES SYS005_ (COD_CONTA_CONTABIL, COD_FILIAL, DATA_CONTA_CONTABIL, COD_EMPRESA)
ALTER TABLE SYS033_ITENS_NFS ADD CONSTRAINT SYS033TNSNFSCDNTPRACAO FOREIGN KEY (COD_NAT_OPERACAO, COD_FILIAL, COD_EMPRESA) REFERENCES SYS031_NATUREZA_OPERACOES (COD_NAT_OPERACAO, COD_FILIAL, COD_EMPRESA)
ALTER TABLE SYS033_ITENS_NFS ADD CONSTRAINT SYS033ITENSNFSCDMPRESA FOREIGN KEY (COD_EMPRESA) REFERENCES SYS000_EMPRESA (COD_EMPRESA)

我将实现从 eclipselink 更改为 hibernate(4.2.1.Final),它成功了!我不知道为什么会出现这个问题,也不知道在这种情况下如何使用eclipselink。