oracle错误(五) Unknown Id.generator: sequenceGenerator的解决办法

前端之家收集整理的这篇文章主要介绍了oracle错误(五) Unknown Id.generator: sequenceGenerator的解决办法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、报错信息:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/D:/workspace_eclipseJee2/.Metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/qpwa-finance/WEB-INF/classes/config/spring/applicationContext-hibernate.xml]: Invocation of init method Failed; nested exception is org.hibernate.AnnotationException: Unknown Id.generator: sequenceGenerator
	at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.initializeBean(AbstractAutowireCapablebeanfactory.java:1512)
	at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:521)
	at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:458)
	at org.springframework.beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:296)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:293)
	at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:194)
	at org.springframework.beans.factory.support.DefaultListablebeanfactory.preInstantiateSingletons(DefaultListablebeanfactory.java:610)
	at org.springframework.context.support.AbstractApplicationContext.finishbeanfactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.hibernate.AnnotationException: Unknown Id.generator: sequenceGenerator
	at org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:506)
	at org.hibernate.cfg.AnnotationBinder.processId(AnnotationBinder.java:2176)
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2088)
	at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:796)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:707)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
	at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
	at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
	at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375)
	at org.springframework.orm.hibernate3.LocalSessionfactorybean.buildSessionFactory(LocalSessionfactorybean.java:720)
	at org.springframework.orm.hibernate3.AbstractSessionfactorybean.afterPropertiesSet(AbstractSessionfactorybean.java:188)
	at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.invokeInitMethods(AbstractAutowireCapablebeanfactory.java:1571)
	at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.initializeBean(AbstractAutowireCapablebeanfactory.java:1509)
	... 21 more

二、解决办法:

import java.io.Serializable;

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;

/**
 * 第三方支付交易流水 实体类
 * @author zengdq
 * @date 2016年10月27日
 */
@Entity
@Table(name = "THIRDPAY_DAY_SEQ")
@SequenceGenerator(name = "sequenceGenerator",sequenceName = "THIRDPAY_DAY_ID_SEQ")
public class ThirdPayDaySeq implements Serializable{
private static final long serialVersionUID = 1L;
	
	/** 主键ID(自增)*/
	private Long id;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO,generator = "sequenceGenerator")
	@Column(name="ID",unique = true,nullable = false)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
}
注:1.THIRDPAY_DAY_ID_SEQ必须对应建表语句中的sequence序列。 原文链接:https://www.f2er.com/oracle/211691.html

猜你在找的Oracle相关文章