Devskiller / jpa2ddl

JPA Schema Generator Plugin
Apache License 2.0
110 stars 33 forks source link

Problem generating @CollectionTable(indexes #36

Closed mikezerosix closed 3 years ago

mikezerosix commented 3 years ago

It works fine on runing project with auto-ddl=create, and it generates the SQL correctly: CREATE INDEX fk_parent_child on child(paretn_id);

But running the plugin with default settings with only packages setting added, I get an error :

Failed to execute goal com.devskiller.jpa2ddl:jpa2ddl-maven-plugin:0.9.12:generate (default-cli) on project Foobaa: Unable to create index (parent_id) on table Parent: database column 'parent_id' not found. Make sure that you use the correct column name which depends on the naming strategy in use (it may not be the same as the property name in the entity, especially for relational types)

@Entity 
public class Parent {

  ...  

  @ElementCollection
  @JoinColumn
  @OnDelete(action = OnDeleteAction.CASCADE)
  @CollectionTable(indexes = {@Index(name = "fk_parent_child", columnList = "parent_id")})
  public final Set<Child> owners = new HashSet<>();
jkubrynski commented 3 years ago

The problem is with resolving unique constraints in H2. This is going to work correctly with resolving #40