Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates: JPA 2.1 @ForeignKey #168

Closed
deafff opened this issue Feb 10, 2015 · 7 comments
Closed

Templates: JPA 2.1 @ForeignKey #168

deafff opened this issue Feb 10, 2015 · 7 comments
Assignees
Milestone

Comments

@deafff
Copy link

deafff commented Feb 10, 2015

3.1.0-SNAPSHOT is still using Hibernate @ForeignKey which was deprecated after v4.3.0. I'm now getting lots of warnings and JPA validation errors (foreign keys missing in the table).

import org.hibernate.annotations.ForeignKey;

should be changed to

import javax.persistence.ForeignKey;

and annotations like

@JoinColumn(name = "COUNTRY_ID", nullable = false)
@ForeignKey(name = "FK_CITY_COUNTRY_ID")

to JPA 2.1 compliant

@JoinColumn(name = "COUNTRY_ID", nullable = false, foreignKey=@ForeignKey(name="FK_CITY_COUNTRY_ID"))
@tjuerge tjuerge self-assigned this Feb 10, 2015
@tjuerge tjuerge added this to the 3.1.0 milestone Feb 10, 2015
@tjuerge
Copy link
Member

tjuerge commented Feb 10, 2015

This is missing from #139.

@tjuerge tjuerge changed the title JPA 2.1 @ForeignKey Templates: JPA 2.1 @ForeignKey Feb 10, 2015
@tjuerge
Copy link
Member

tjuerge commented Feb 15, 2015

Using the JPA annotation @ForeignKey means we have to support different JPA versions (again) in Sculptor (depending on the JPA provider):

  • JPA 2.1 for Hibernate, Eclipse Link and DataNucleus
  • JPA 2.0 for OpenJPA and Google AppEngine (via DataNucleus plugin)

So we have to set the JPA version in persistence.xml in accordance to the JPA provider.

@tjuerge
Copy link
Member

tjuerge commented Feb 15, 2015

It seems that the JPA 2.1 annotation @ForeignKeydoesn't work in Hibernate 4.3.x fully:

@tjuerge
Copy link
Member

tjuerge commented Feb 15, 2015

With Hibernate 6 the deprecated annotation will be removed (HHH-8969).

@tjuerge tjuerge removed their assignment Feb 16, 2015
@tjuerge tjuerge removed this from the 3.1.0 milestone Feb 19, 2015
@tjuerge tjuerge added enhancement and removed bug labels Feb 19, 2015
@tjuerge tjuerge removed the 1 - Ready label Jan 9, 2016
@matt-hao
Copy link

hello tjuerge , i'm a freshman to learn jpa. i have also meet this problem, can u tell me how to solve this ?

@tavoda
Copy link
Member

tavoda commented Sep 14, 2017

Because a lot changes in Hibernate 5.2 which are preparation steps for 6 we have to make at least Enum template to recognize Hibernate > 5.2 I will try to improve generation of foreign key when 5.2 is specified. First idea is to use option jpa.provider=hibernate52.

@tavoda tavoda self-assigned this Sep 14, 2017
@Ysosa
Copy link

Ysosa commented Feb 23, 2018

to JPA 2.1 compliant

@joincolumn(name = "COUNTRY_ID", nullable = false, foreignKey=@foreignkey(name="FK_CITY_COUNTRY_ID"))

Its work fine!! thank u

@tjuerge tjuerge added this to the 3.2.0 milestone May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants