[hibernate-issues] [JIRA] (HHH-14123) @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) doesn't work

Murilo Carlos Cardoso (JIRA) jira at hibernate.atlassian.net
Tue Jul 28 13:00:36 EDT 2020


Murilo Carlos Cardoso ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5f2056e1c9c094001c5a47a6 ) *created* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTQ3YjExNzU2ODY2NDQyMGIwZTFjODVhMzA5NWQyYzkiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14123?atlOrigin=eyJpIjoiYTQ3YjExNzU2ODY2NDQyMGIwZTFjODVhMzA5NWQyYzkiLCJwIjoiaiJ9 ) HHH-14123 ( https://hibernate.atlassian.net/browse/HHH-14123?atlOrigin=eyJpIjoiYTQ3YjExNzU2ODY2NDQyMGIwZTFjODVhMzA5NWQyYzkiLCJwIjoiaiJ9 ) @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) doesn't work ( https://hibernate.atlassian.net/browse/HHH-14123?atlOrigin=eyJpIjoiYTQ3YjExNzU2ODY2NDQyMGIwZTFjODVhMzA5NWQyYzkiLCJwIjoiaiJ9 )

Issue Type: Bug Assignee: Unassigned Components: hibernate-core Created: 28/Jul/2020 10:00 AM Environment: Hibernate version 5.4.18.Final.
OpenJDK 11
Linux Mint 19
Postgres Priority: Major Reporter: Murilo Carlos Cardoso ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5f2056e1c9c094001c5a47a6 )

@JoinColumn(foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) doesn't work.

Example:

public class ClassA {

   @Id
   private String id;
   
   @NotNull
   private String someProperty;
   
   @OneToMany(mappedBy = " classA " )
   private Set<ClassB> bs;
}

public class ClassB {
   
   @Id
   private String id;
   
   @NotNull
   private String someProperty;
   
   @ManyToOne
   @JoinColumn(foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
   private ClassA classA ;
}

When the application starts it still creates the fks, although I have explicit configure to not.

create table class_a (id varchar(255) not null , some_property varchar(255), primary key (id));
  
create table class_b (id varchar(255) not null , some_property varchar(255), class_a_id varchar(255), primary key (id));

alter table if exists class_b add constraint FKjpk05raxduof60eee8p6khbch foreign key (class_a_id) references class_a

application.properties

spring.datasource.url=jdbc:postgresql: //localhost:5432/my-spring-data-sample
spring.datasource.username=postgres
spring.datasource.password=***

spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.generate-ddl= true
spring.jpa.show-sql= true
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL95Dialect

( https://hibernate.atlassian.net/browse/HHH-14123#add-comment?atlOrigin=eyJpIjoiYTQ3YjExNzU2ODY2NDQyMGIwZTFjODVhMzA5NWQyYzkiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14123#add-comment?atlOrigin=eyJpIjoiYTQ3YjExNzU2ODY2NDQyMGIwZTFjODVhMzA5NWQyYzkiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100140- sha1:454f3ac )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200728/fb8aa37b/attachment.html 


More information about the hibernate-issues mailing list