Oracle操作ORA-02289: 序列不存在 解决方案_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > Oracle操作ORA-02289: 序列不存在 解决方案

Oracle操作ORA-02289: 序列不存在 解决方案

 2013/12/15 19:09:03  boonya  程序员俱乐部  我要评论(0)
  • 摘要:1、创建序列--CreatesequencecreatesequenceDEMO_SEQminvalue1maxvalue999999999999999999999999999startwith1incrementby1cache20;2、Java实体对象配置packagecom.boonya.demo.business.entity;importjava.io.Serializable;importjavax.persistence.Column;importjavax
  • 标签:解决方案 解决 ORA 操作 Oracle
1、创建序列
class="sql">-- Create sequence 
create sequence DEMO_SEQ
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
cache 20;


2、Java实体对象配置
package com.boonya.demo.business.entity;

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;
import javax.persistence.Transient;

@Entity
@Table(name="demo")
public class Demo implements Serializable
{
	private static final long serialVersionUID = -6933265249358475103L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE,generator="demo_emp_seq")   
	@SequenceGenerator(name="demo_emp_seq", sequenceName="DEMO_SEQ")
	@Column(name="ID",columnDefinition = "int(11)", nullable = false)
	private int id;             // 编号
	
	@Column(name="NAME",columnDefinition = "nvarchar2(30)", nullable = false)
	private String name;        // 名称
	
	@Column(name="NOTE",columnDefinition = "varchar2(100)", nullable = true)
	private String note;       //  备注
	
	@Transient
	private String tempField;  //  临时字段
	
	public Demo()
	{
	}
	public Demo(String name,String note)
	{
		this.name=name;
		this.note=note;
	}
	public Demo(int id,String name,String note)
	{
		this.id=id;
		this.name=name;
		this.note=note;
	}
	public int getId()
	{
		return id;
	}
	public void setId(int id)
	{
		this.id = id;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public String getNote()
	{
		return note;
	}
	public void setNote(String note)
	{
		this.note = note;
	}
	public String getTempField()
	{
		return tempField;
	}
	public void setTempField(String tempField)
	{
		this.tempField = tempField;
	}
	
}  

注:必须实现可序列化接口
发表评论
用户名: 匿名