oracle 实现自动增长
2008-06-06 13:59
423 查看
数据库设计:
在oracle 创建表 :
create table test (in int ,loginname varchar(128),loginpass varchar(128));
alter table test add constraint primary key(id);
在oracle 创建sequence:
create sequence seq_id
minvalue 1
start with 1
increment by 1
cache 20;
java代码:
pojo类:
package com.pojo;
/**
* Test generated by MyEclipse - Hibernate Tools
*/
public class Test implements java.io.Serializable {
// Fields
private long id;
private String name;
private String pass;
// Constructors
/** default constructor */
public Test() {
}
/** minimal constructor */
public Test(long id) {
this.id = id;
}
/** full constructor */
public Test(long id, String name, String pass) {
this.id = id;
this.name = name;
this.pass = pass;
}
// Property accessors
public long getId() {
return this.id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getPass() {
return this.pass;
}
public void setPass(String pass) {
this.pass = pass;
}
xml映射文件:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.pojo.Test" table="TEST" schema="WTL">
<id name="id" type="long">
<column name="ID" precision="22" scale="0" />
<generator class="sequence">
<param name="sequence">seq_id</param>----------关键代码
</generator>
</id>
<property name="name" type="string">
<column name="NAME" length="128" />
</property>
<property name="pass" type="string">
<column name="PASS" length="128" />
</property>
</class>
</hibernate-mapping>
在oracle 创建表 :
create table test (in int ,loginname varchar(128),loginpass varchar(128));
alter table test add constraint primary key(id);
在oracle 创建sequence:
create sequence seq_id
minvalue 1
start with 1
increment by 1
cache 20;
java代码:
pojo类:
package com.pojo;
/**
* Test generated by MyEclipse - Hibernate Tools
*/
public class Test implements java.io.Serializable {
// Fields
private long id;
private String name;
private String pass;
// Constructors
/** default constructor */
public Test() {
}
/** minimal constructor */
public Test(long id) {
this.id = id;
}
/** full constructor */
public Test(long id, String name, String pass) {
this.id = id;
this.name = name;
this.pass = pass;
}
// Property accessors
public long getId() {
return this.id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getPass() {
return this.pass;
}
public void setPass(String pass) {
this.pass = pass;
}
xml映射文件:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.pojo.Test" table="TEST" schema="WTL">
<id name="id" type="long">
<column name="ID" precision="22" scale="0" />
<generator class="sequence">
<param name="sequence">seq_id</param>----------关键代码
</generator>
</id>
<property name="name" type="string">
<column name="NAME" length="128" />
</property>
<property name="pass" type="string">
<column name="PASS" length="128" />
</property>
</class>
</hibernate-mapping>
相关文章推荐
- 如何实现oracle中的某个字段自动增长
- oracle主键自动增长的实现 Oracle Sequence oracle maxid自动生成--ORA-00001: 违反唯一约束条件 (NAME.SYS_C005547)产生的原因之一(select * from all_cons_columns w
- Oracle和SQLSERVER实现主键自动增长
- Oracle中实现自动增长列
- oracle实现主键自动增长
- oracle 主键应用序列和触发器实现自动增长
- Oracle 自动生成编号(实现sqlserver自增长字段)
- Oracle利用序列实现自动增长列
- Oracle实现列的自动增长
- Oracle利用序列实现自动增长列
- Oracle 表创建序列-触发 实现表ID自动增长
- Oracle 自动生成编号(实现sqlserver自增长字段)
- Oracle 自动生成编号(实现sqlserver自增长字段)
- 在oracle中实现自动增长的列号(例子
- 在hibernate中实现oracle的自动增长
- oracle实现自动增长列
- Oracle 自动生成编号(实现sqlserver自增长字段)
- oracle实现自动插入自增长序列
- oracle中自动增长列的实现
- 在hibernate中实现oracle的自动增长