配置1 及对应的数据字段
ProductAttributeValue.hbm.xml:
<hibernate-mapping
>
<class
name="com.pubone.eet.model.ProductAttributeValue"
table="eb_prd_opt_attri_value"
><id
name="productAttributeValueId"
column="product_attribute_value_id"
type="java.lang.Long"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-ProductAttributeValue.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="attributeValue"
type="java.lang.String"
update="true"
insert="true"
length="255"
>
<column
name="attribute_value"
/>
</property>
<property
name="sortOrder"
type="int"
update="true"
insert="true"
>
<column
name="sort_Order"
sql-type="number(3)"
/>
</property> <property
name="idType"
type="int"
update="true"
insert="true"
>
<column
name="id_type"
length="1"
sql-type="smallint"
/>
</property><property
name="idValue"
type="java.lang.Long"
update="true"
insert="true"
>
<column
name="id_value"
/>
</property><property
name="textFieldValue"
type="java.lang.String"
update="true"
insert="true"
>
<column
name="text_field_value"
length="255"
default="''"
/>
</property><property
name="intFieldValue"
type="int"
update="true"
insert="true"
>
<column
name="int_field_value"
/>
</property><property
name="floatFieldValue"
type="float"
update="true"
insert="true"
>
<column
name="float_field_value"
/>
</property><property
name="dateFieldValue"
type="timestamp"
update="true"
insert="true"
>
<column
name="date_field_value"
/>
</property>
<many-to-one
name="productAttribute"
column="attribute_id"
class="com.pubone.eet.model.ProductAttribute"
cascade="none"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ProductAttributeValue.xml
containing the additional properties and place it in your merge dir.
--></class>
create table "QQTEXUSER"."EB_PRD_OPT_ATTRI_VALUE"(
"PRODUCT_ATTRIBUTE_VALUE_ID" NUMBER(19) not null,
"ATTRIBUTE_ID" NUMBER(19),
"SORT_ORDER" NUMBER(3),
"ATTRIBUTE_VALUE" VARCHAR2(255),
"ID_TYPE" NUMBER(3),
"ID_VALUE" NUMBER(3),
"TEXT_FIELD_VALUE" VARCHAR2(255),
"INT_FIELD_VALUE" NUMBER(3),
"FLOAT_FIELD_VALUE" NUMBER(9,3),
"DATE_FIELD_VALUE" DATE,
constraint "SYS_C0010287" primary key ("PRODUCT_ATTRIBUTE_VALUE_ID")
);alter table "QQTEXUSER"."EB_PRD_OPT_ATTRI_VALUE"
add constraint "FK45F1E91CE0B52995"
foreign key ("ATTRIBUTE_ID")
references "QQTEXUSER"."EB_PRODUCT_OPTION_ATTRIBUTE"("ATTRIBUTE_ID");
create unique index "QQTEXUSER"."SYS_C0010287" on "QQTEXUSER"."EB_PRD_OPT_ATTRI_VALUE"("PRODUCT_ATTRIBUTE_VALUE_ID");配置2 及对应的数据字段
ProductAttribute.hbm.xml:
<hibernate-mapping
>
<class
name="com.pubone.eet.model.ProductAttribute"
table="eb_product_attribute"
><id
name="attributeId"
column="attribute_id"
type="java.lang.Long"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-ProductAttribute.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id><property
name="name"
type="java.lang.String"
update="true"
insert="true"
>
<column
name="option_value_name"
length="64"
default="''"
/>
</property><property
name="dataType"
type="int"
update="true"
insert="true"
>
<column
name="data_type"
length="1"
sql-type="smallint"
/>
</property><property
name="status"
type="int"
update="true"
insert="true"
>
<column
name="status"
length="1"
sql-type="smallint"
/>
</property><property
name="creator"
type="java.lang.String"
update="true"
insert="true"
>
<column
name="creator"
length="100"
default="''"
/>
</property><property
name="createdDate"
type="timestamp"
update="true"
insert="true"
>
<column
name="created_date"
/>
</property><property
name="modifiedDate"
type="timestamp"
update="true"
insert="true"
>
<column
name="modified_date"
/>
</property><property
name="mender"
type="java.lang.String"
update="true"
insert="true"
>
<column
name="mender"
length="100"
default="''"
/>
</property><property
name="sortOrder"
type="int"
update="true"
insert="true"
>
<column
name="sort_order"
/>
</property><property
name="isNeeded"
type="int"
update="true"
insert="true"
>
<column
name="is_Needed"
sql-type="number(1)"
/>
</property> <property
name="valueDisplayType"
type="int"
update="true"
insert="true"
>
<column
name="value_Display_Type"
sql-type="number(1)"
/>
</property><many-to-one
name="businessCategory"
class="com.pubone.eet.model.BusinessCategory"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="business_category_id"
/><set
name="productAttributeValue" lazy="true"
inverse="false"
cascade="all"
sort="unsorted"
><key
column="attribute_id"
>
</key><one-to-many
class="com.pubone.eet.model.ProductAttributeValue"
/></set><!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ProductAttribute.xml
containing the additional properties and place it in your merge dir.
--></class>
create table "QQTEXUSER"."EB_PRODUCT_ATTRIBUTE"(
"ATTRIBUTE_ID" NUMBER(10) not null,
"BUSINESS_CATEGORY_ID" NUMBER(10),
"ATTRIBUTE_NAME" VARCHAR2(64),
"DATA_TYPE" NUMBER(1),
"STATUS" NUMBER(3),
"CREATOR" VARCHAR2(100),
"CREATED_DATE" DATE,
"MODIFIED_DATE" DATE,
"MENDER" VARCHAR2(100),
"SORT_ORDER" NUMBER(3),
"IS_NEEDED" NUMBER(3),
"ATTRIBUTE_VALUE_DISPAY" NUMBER(3),
"VALUE_DISPLAY_TYPE" NUMBER(3),
"OPTION_VALUE_NAME" VARCHAR2(64),
constraint "SYS_C0012177" primary key ("ATTRIBUTE_ID")
);alter table "QQTEXUSER"."EB_PRODUCT_ATTRIBUTE"
add constraint "PRO_ATTRI_CATE_FK"
foreign key ("BUSINESS_CATEGORY_ID")
references "QQTEXUSER"."EB_BUSINESS_CATEGORY"("BUSINESS_CATEGORY_ID");
create unique index "QQTEXUSER"."SYS_C0012177" on "QQTEXUSER"."EB_PRODUCT_ATTRIBUTE"("ATTRIBUTE_ID");
ProductAttributeValue.hbm.xml:
<hibernate-mapping
>
<class
name="com.pubone.eet.model.ProductAttributeValue"
table="eb_prd_opt_attri_value"
><id
name="productAttributeValueId"
column="product_attribute_value_id"
type="java.lang.Long"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-ProductAttributeValue.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="attributeValue"
type="java.lang.String"
update="true"
insert="true"
length="255"
>
<column
name="attribute_value"
/>
</property>
<property
name="sortOrder"
type="int"
update="true"
insert="true"
>
<column
name="sort_Order"
sql-type="number(3)"
/>
</property> <property
name="idType"
type="int"
update="true"
insert="true"
>
<column
name="id_type"
length="1"
sql-type="smallint"
/>
</property><property
name="idValue"
type="java.lang.Long"
update="true"
insert="true"
>
<column
name="id_value"
/>
</property><property
name="textFieldValue"
type="java.lang.String"
update="true"
insert="true"
>
<column
name="text_field_value"
length="255"
default="''"
/>
</property><property
name="intFieldValue"
type="int"
update="true"
insert="true"
>
<column
name="int_field_value"
/>
</property><property
name="floatFieldValue"
type="float"
update="true"
insert="true"
>
<column
name="float_field_value"
/>
</property><property
name="dateFieldValue"
type="timestamp"
update="true"
insert="true"
>
<column
name="date_field_value"
/>
</property>
<many-to-one
name="productAttribute"
column="attribute_id"
class="com.pubone.eet.model.ProductAttribute"
cascade="none"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ProductAttributeValue.xml
containing the additional properties and place it in your merge dir.
--></class>
create table "QQTEXUSER"."EB_PRD_OPT_ATTRI_VALUE"(
"PRODUCT_ATTRIBUTE_VALUE_ID" NUMBER(19) not null,
"ATTRIBUTE_ID" NUMBER(19),
"SORT_ORDER" NUMBER(3),
"ATTRIBUTE_VALUE" VARCHAR2(255),
"ID_TYPE" NUMBER(3),
"ID_VALUE" NUMBER(3),
"TEXT_FIELD_VALUE" VARCHAR2(255),
"INT_FIELD_VALUE" NUMBER(3),
"FLOAT_FIELD_VALUE" NUMBER(9,3),
"DATE_FIELD_VALUE" DATE,
constraint "SYS_C0010287" primary key ("PRODUCT_ATTRIBUTE_VALUE_ID")
);alter table "QQTEXUSER"."EB_PRD_OPT_ATTRI_VALUE"
add constraint "FK45F1E91CE0B52995"
foreign key ("ATTRIBUTE_ID")
references "QQTEXUSER"."EB_PRODUCT_OPTION_ATTRIBUTE"("ATTRIBUTE_ID");
create unique index "QQTEXUSER"."SYS_C0010287" on "QQTEXUSER"."EB_PRD_OPT_ATTRI_VALUE"("PRODUCT_ATTRIBUTE_VALUE_ID");配置2 及对应的数据字段
ProductAttribute.hbm.xml:
<hibernate-mapping
>
<class
name="com.pubone.eet.model.ProductAttribute"
table="eb_product_attribute"
><id
name="attributeId"
column="attribute_id"
type="java.lang.Long"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-ProductAttribute.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id><property
name="name"
type="java.lang.String"
update="true"
insert="true"
>
<column
name="option_value_name"
length="64"
default="''"
/>
</property><property
name="dataType"
type="int"
update="true"
insert="true"
>
<column
name="data_type"
length="1"
sql-type="smallint"
/>
</property><property
name="status"
type="int"
update="true"
insert="true"
>
<column
name="status"
length="1"
sql-type="smallint"
/>
</property><property
name="creator"
type="java.lang.String"
update="true"
insert="true"
>
<column
name="creator"
length="100"
default="''"
/>
</property><property
name="createdDate"
type="timestamp"
update="true"
insert="true"
>
<column
name="created_date"
/>
</property><property
name="modifiedDate"
type="timestamp"
update="true"
insert="true"
>
<column
name="modified_date"
/>
</property><property
name="mender"
type="java.lang.String"
update="true"
insert="true"
>
<column
name="mender"
length="100"
default="''"
/>
</property><property
name="sortOrder"
type="int"
update="true"
insert="true"
>
<column
name="sort_order"
/>
</property><property
name="isNeeded"
type="int"
update="true"
insert="true"
>
<column
name="is_Needed"
sql-type="number(1)"
/>
</property> <property
name="valueDisplayType"
type="int"
update="true"
insert="true"
>
<column
name="value_Display_Type"
sql-type="number(1)"
/>
</property><many-to-one
name="businessCategory"
class="com.pubone.eet.model.BusinessCategory"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="business_category_id"
/><set
name="productAttributeValue" lazy="true"
inverse="false"
cascade="all"
sort="unsorted"
><key
column="attribute_id"
>
</key><one-to-many
class="com.pubone.eet.model.ProductAttributeValue"
/></set><!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ProductAttribute.xml
containing the additional properties and place it in your merge dir.
--></class>
create table "QQTEXUSER"."EB_PRODUCT_ATTRIBUTE"(
"ATTRIBUTE_ID" NUMBER(10) not null,
"BUSINESS_CATEGORY_ID" NUMBER(10),
"ATTRIBUTE_NAME" VARCHAR2(64),
"DATA_TYPE" NUMBER(1),
"STATUS" NUMBER(3),
"CREATOR" VARCHAR2(100),
"CREATED_DATE" DATE,
"MODIFIED_DATE" DATE,
"MENDER" VARCHAR2(100),
"SORT_ORDER" NUMBER(3),
"IS_NEEDED" NUMBER(3),
"ATTRIBUTE_VALUE_DISPAY" NUMBER(3),
"VALUE_DISPLAY_TYPE" NUMBER(3),
"OPTION_VALUE_NAME" VARCHAR2(64),
constraint "SYS_C0012177" primary key ("ATTRIBUTE_ID")
);alter table "QQTEXUSER"."EB_PRODUCT_ATTRIBUTE"
add constraint "PRO_ATTRI_CATE_FK"
foreign key ("BUSINESS_CATEGORY_ID")
references "QQTEXUSER"."EB_BUSINESS_CATEGORY"("BUSINESS_CATEGORY_ID");
create unique index "QQTEXUSER"."SYS_C0012177" on "QQTEXUSER"."EB_PRODUCT_ATTRIBUTE"("ATTRIBUTE_ID");
2007-10-26 10:27:51,818 ERROR [org.hibernate.util.JDBCExceptionReporter] - <ORA-02291: 违反完整约束条件 (QQTEXUSER.FK45F1E91CE0B52995) - 未找到父项关键字
>
2007-10-26 10:27:51,818 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 2291, SQLState: 23000>
2007-10-26 10:27:51,818 ERROR [org.hibernate.util.JDBCExceptionReporter] - <ORA-02291: 违反完整约束条件 (QQTEXUSER.FK45F1E91CE0B52995) - 未找到父项关键字
>
2007-10-26 10:27:51,818 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] - <Could not synchronize database state with session>
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:632)
at com.pubone.eet.dao.hibernate.ProductAttributeDAOImpl.saveProductAttributeValue(ProductAttributeDAOImpl.java:134)
at com.pubone.eet.service.ProductAttributeManager.saveProductAttributeValue(ProductAttributeManager.java:49)
at com.pubone.eet.controller.ProductAttributeController.addAdditionAttributeValue(ProductAttributeController.java:481)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:428)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:366)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:857)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:475)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:440)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.pubone.filter.RequestFilter.doFilter(RequestFilter.java:45)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:834)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.BatchUpdateException: ORA-02291: 违反完整约束条件 (QQTEXUSER.FK45F1E91CE0B52995) - 未找到父项关键字at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
建议看下数据库主外键关系和hibernate生成的PO对象中的主外键关系是否一致,
还有lazy建议设置为“false”,要不批量修改可能会有问题~~~~