|
create table HGZXX(
id NUMBER(19),
ERPDDH VARCHAR2(255),WZBM VARCHAR2(255),
WZMC VARCHAR2(255),GGXH VARCHAR2(255),
ZJ VARCHAR2(255),FDJXH VARCHAR2(255),
HXCC VARCHAR2(255),WKCC VARCHAR2(255),
LTGG VARCHAR2(255),THPS VARCHAR2(255),
ZZRS VARCHAR2(255),SCYQ VARCHAR2(255),
EJSHDZBM VARCHAR2(255),EJSHDZMC VARCHAR2(255)
)
tablespace JAC_SCL
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64
);
-- Create sequence
create sequence SEQ_HGZXX
minvalue 1--最小值
maxvalue 999999999999999999999999999--最大值
start with 1000--开始于
increment by 1--增量
cache 20;--高速缓存大小
延伸:
-- Create table
create table BILL
(
id NUMBER(19) not null,
company_id NUMBER(19),
organization_id NUMBER(19),
fee_category_id NUMBER(19),
invoice_id NUMBER(19),
amount FLOAT,
billing_type VARCHAR2(20 CHAR),
bill_no VARCHAR2(20 CHAR) not null,
description VARCHAR2(255 CHAR),
month NUMBER(10),
year NUMBER(10),
status VARCHAR2(20 CHAR),
product_type VARCHAR2(100 CHAR),
transportation_mode VARCHAR2(20 CHAR)
)
tablespace JAC_SCL
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64
);
-- Create/Recreate primary, unique and foreign key constraints
alter table BILL
add primary key (ID)
using index
tablespace JAC_SCL
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
);
alter table BILL
add unique (BILL_NO)
using index
tablespace JAC_SCL
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
);
alter table BILL
add constraint FK1F1C0786F4F40D foreign key (INVOICE_ID)
references INVOICE (ID);
alter table BILL
add constraint FK1F1C078CB5B97D foreign key (ORGANIZATION_ID)
references WMS_ORGANIZATION (ID);
alter table BILL
add constraint FK1F1C07B1EADF3 foreign key (COMPANY_ID)
references WMS_ORGANIZATION (ID);
alter table BILL
add constraint FK1F1C07E9E93F5A foreign key (FEE_CATEGORY_ID)
references FEE_CATEGORY (ID);
对应的hbm配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.vtradex.stms.server.model.billing.Bill" table="BILL">
<id name="id" column="ID" type="long">
<generator class="native">
<param name="sequence">seq_bill</param>
<param name="parameters">START WITH 1000</param>
</generator>
</id>
<many-to-one name="company" class="com.vtradex.stms.server.model.base.Organization">
<column name="COMPANY_ID" ></column>
</many-to-one>
<many-to-one name="organization" class="com.vtradex.stms.server.model.base.Organization">
<column name="ORGANIZATION_ID" ></column>
</many-to-one>
<set name="fees" table="FEE" lazy="true" inverse="true">
<key column="BILL_ID"></key>
<one-to-many class="com.vtradex.stms.server.model.billing.Fee"/>
</set>
<many-to-one name="feeCategory" class="com.vtradex.stms.server.model.billing.FeeCategory">
<column name="FEE_CATEGORY_ID" ></column>
</many-to-one>
<many-to-one name="invoice" class="com.vtradex.stms.server.model.billing.Invoice">
<column name="INVOICE_ID" ></column>
</many-to-one>
<property name="amount" column="AMOUNT" type="double" />
<property name="billingType" column="BILLING_TYPE" type="string" length="20"/>
<property name="billNo" column="BILL_NO" type="string" length="20" not-null="true" unique-key="UK_BILL_NO"/>
<property name="description" column="DESCRIPTION" type="string" length="255"/>
<property name="month" column="MONTH" type="integer"/>
<property name="year" column="YEAR" type="integer"/>
<property name="status" column="STATUS" type="string" length="20"/>
<property name="productType" column="PRODUCT_TYPE" type="string" length="100"/>
<property name="transportationMode" column="TRANSPORTATION_MODE" type="string" length="20"/>
</class>
</hibernate-mapping>
|
|
|