У меня есть MapperSuperclass под названием BaseTable:
@MappedSuperclass
public abstract class BaseTable {
@Column(
length = 100
)
private String myColumn;
....
}
и сущность, которая расширяется от BaseTable под названием Table
@Entity
@org.hibernate.annotations.Entity(
dynamicUpdate = true
)
@Inheritance(
strategy = InheritanceType.SINGLE_TABLE
)
public class Table extends BaseTable {
....
}
Теперь я хочу расширить Table
и добавить уникальный ограничение на столбец myColumn
. Я попробовал переопределить атрибут, как показано ниже:
@Entity
@AttributeOverride(name = "myColumn", column = @Column(name = "my_column", unique = true))
public class MyTable extends Table {
.....
}
Но это дает мне следующую ошибку:
org.hibernate.AnnotationException: An entity annotated with @Inheritance cannot use @AttributeOverride or @AttributeOverrides: com.example.demo.MyTable
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:404) [spring-beans-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:563) [spring-web-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:322) [spring-web-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:216) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:185) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:250) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_222]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_222]
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_222]
at org.jboss.threads.JBossThread.run(JBossThread.java:485)
Скажите, что мне не разрешено изменять BaseTable и Table, поскольку они исходят из добавлены библиотеки, как добавить уникальное ограничение в столбец myColumn
?