How to use @UniqueConstraint with single table inheritance (JPA)?

后端 未结 1 1763
花落未央
花落未央 2021-01-06 20:41

I have a class extending an existing entity with single table strategy (which I can\'t change). I want to use UniqueConstraint for that entity so I tried:

@E         


        
1条回答
  •  甜味超标
    2021-01-06 20:46

    You cannot override the base class @Table declaration, that's why the sub-class uniqueConstraints directive is ignored.

    With JPA you can override annotations with xml declarations. So you need to add an orm.xml file in your class-pat and add the unique constraints there:

    
    
        ...
        
            
                    first_column
                    second_column
                

    This way you might not even need the MyDocument sub-class, if you only used it to override the DDL schema.

    0 讨论(0)
提交回复
热议问题