我正在使用Apache Derby DB的hibernate。当我要构建我的应用程序时,我收到错误
Derby不支持发布10.6.1.0之前的序列
我正在使用hibernate和derby jar进入我的应用程序。
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.11.1.1</version>
</dependency>
从此link开始,Apache Derby DB现在支持这些序列。
关注此link,但在此问题上找不到多少帮助。
实体类如下: -
package rest.food.ordering.model;
import java.math.BigInteger;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@Entity
@Table(name="SERVING_LOCATION")
public class ServingLocation {
@Id
@GeneratedValue(generator = "SER_LOC_SEQ", strategy = GenerationType.SEQUENCE)
@SequenceGenerator(name = "SER_LOC_SEQ", sequenceName = "SERVING_LOCATION_SEQUENCE", allocationSize=1,initialValue=1)
@Column(name="LOCATION_ID",nullable = false)
private BigInteger locationId;
@Column(name="LOCATION_NAME",nullable = false, length = 100)
private String locationName;
public BigInteger getLocationId() {
return locationId;
}
public void setLocationId(BigInteger locationId) {
this.locationId = locationId;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
}
错误的StackTrace如下: -
17:02:30,934 ERROR [stderr] (ServerService Thread Pool -- 137) org.hibernate.MappingException: Could not instantiate id generator [entity-name=rest.food.ordering.model.ServingLocation]
17:02:30,935 ERROR [stderr] (ServerService Thread Pool -- 137) at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.createIdentifierGenerator(DefaultIdentifierGeneratorFactory.java:123)
17:02:30,935 ERROR [stderr] (ServerService Thread Pool -- 137) at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:213)
17:02:30,935 ERROR [stderr] (ServerService Thread Pool -- 137) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:323)
17:02:30,935 ERROR [stderr] (ServerService Thread Pool -- 137) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)
17:02:30,935 ERROR [stderr] (ServerService Thread Pool -- 137) at rest.food.ordering.utils.HibernateUtils.getSessionFactoryObject(HibernateUtils.java:44)
17:02:30,935 ERROR [stderr] (ServerService Thread Pool -- 137) at rest.food.ordering.dao.FoodOrderingDaoImpl.<clinit>(FoodOrderingDaoImpl.java:21)
17:02:30,935 ERROR [stderr] (ServerService Thread Pool -- 137) at rest.food.ordering.configuration.AppBeansConfig.getFoodOrderingDaoObj(AppBeansConfig.java:14)
17:02:30,935 ERROR [stderr] (ServerService Thread Pool -- 137) at rest.food.ordering.configuration.AppBeansConfig$$EnhancerBySpringCGLIB$$f82ba1fe.CGLIB$getFoodOrderingDaoObj$0(<generated>)
17:02:30,935 ERROR [stderr] (ServerService Thread Pool -- 137) at rest.food.ordering.configuration.AppBeansConfig$$EnhancerBySpringCGLIB$$f82ba1fe$$FastClassBySpringCGLIB$$ce1e0aa.invoke(<generated>)
17:02:30,935 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:318)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at rest.food.ordering.configuration.AppBeansConfig$$EnhancerBySpringCGLIB$$f82ba1fe.getFoodOrderingDaoObj(<generated>)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at java.lang.reflect.Method.invoke(Method.java:498)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
17:02:30,936 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1145)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1069)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:967)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:543)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
17:02:30,937 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1145)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1069)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:967)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:543)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
17:02:30,938 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:198)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
17:02:30,939 ERROR [stderr] (ServerService Thread Pool -- 137) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
17:02:30,940 ERROR [stderr] (ServerService Thread Pool -- 137) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
17:02:30,940 ERROR [stderr] (ServerService Thread Pool -- 137) at java.util.concurrent.FutureTask.run(FutureTask.java:266)
17:02:30,940 ERROR [stderr] (ServerService Thread Pool -- 137) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
17:02:30,940 ERROR [stderr] (ServerService Thread Pool -- 137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
17:02:30,940 ERROR [stderr] (ServerService Thread Pool -- 137) at java.lang.Thread.run(Thread.java:745)
17:02:30,940 ERROR [stderr] (ServerService Thread Pool -- 137) at org.jboss.threads.JBossThread.run(JBossThread.java:320)
17:02:30,940 ERROR [stderr] (ServerService Thread Pool -- 137) Caused by: org.hibernate.MappingException: Derby does not support sequence prior to release 10.6.1.0
17:02:30,940 ERROR [stderr] (ServerService Thread Pool -- 137) at org.hibernate.dialect.DerbyDialect.getSequenceNextValString(DerbyDialect.java:136)
17:02:30,940 ERROR [stderr] (ServerService Thread Pool -- 137) at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:110)
17:02:30,940 ERROR [stderr] (ServerService Thread Pool -- 137) at org.hibernate.id.SequenceHiLoGenerator.configure(SequenceHiLoGenerator.java:55)
17:02:30,941 ERROR [stderr] (ServerService Thread Pool -- 137) at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.createIdentifierGenerator(DefaultIdentifierGeneratorFactory.java:117)
17:02:30,941 ERROR [stderr] (ServerService Thread Pool -- 137) ... 67 more
在这个问题上帮助我。