改成Assigned,自己设置了主键,写Oracle的时候,也是上面的问题.
晕死了.难道是数据库的表有问题?
晕死了.难道是数据库的表有问题?
解决方案 »
- 我从服务器那边传递过来的json数据解析不了
- 请教个问题,网络编程怎么获取用的mac地址(网页中),请高手指教
- Java过滤器过滤用户是否登录问题
- 关于一个一面跳转问题
- MDB is unable to connect to jms destination, Foreign Destinati
- 高手幫忙啊
- 一个weblogic的问题,网站正常运行一段时间后,会报空指针
- 很简单的 数据库连接问题 谢谢
- java 变量
- Java中String value="Wed Sep 16 19:02:36 CST 2009";怎么将他转回Date类型??跪求大神指教。
- 请问一个关于sitemesh的问题
- 那位大虾,能够解释一下!100分哦!
/*
* Created on Mar 5, 2004
*
* (c) 2004, Mark Eagle, [email protected]
* relased under terms of the GNU public license
* http://www.gnu.org/licenses/licenses.html#TOCGPL
*/
package com.meagle.bo;import java.util.HashSet;
import java.util.Set;/**
* This object represents an order.
*
* @hibernate.class table="Orders"
*
* @author meagle
*/
public class Order { private String id;
private double total;
// The person that placed the order as a simple String
// to keep the example small
private String userName;
// collection of order line items
private Set orderLineItems = new HashSet(); /**
* Default constuctor
*/
public Order() {
super();
} /**
* @hibernate.id generator-class="native" type="int" column="Order_ID" unsaved-value="0"
* @return int
*/
public String getId() {
return id;
}
/**
* @hibernate.set name="orderLineItems" table="OrderLineItem"
* inverse="true"
* cascade="save-update" lazy="true"
* @hibernate.collection-key column="Order_ID"
* @hibernate.collection-one-to-many class="com.meagle.bo.OrderLineItem"
*
* @return Set
*/
public Set getOrderLineItems() {
return orderLineItems;
} /**
* @hibernate.property column="UserName" type="string" not-null="true" unique="false"
* @return String
*/
public String getUserName() {
return userName;
} /**
* @hibernate.property name="total" column="Total" type="double" not-null="false" unique="false"
*
* @return double
*/
public double getTotal() {
return total;
} /**
* @param i
*/
public void setId(String i) {
id = i;
} /**
* @param string
*/
public void setUserName(String string) {
userName = string;
} /**
* @param d
*/
public void setTotal(double d) {
total = d;
} /**
* @param set
*/
public void setOrderLineItems(Set set) {
orderLineItems = set;
}}
-----------------------------------------------------------------------
OrderLineItem.java
/*
* Created on Mar 5, 2004
*
* (c) 2004, Mark Eagle, [email protected]
* relased under terms of the GNU public license
* http://www.gnu.org/licenses/licenses.html#TOCGPL
*/
package com.meagle.bo;/**
* Simple order line item representation
*
* @hibernate.class table="OrderLineItem"
*
* @author meagle
*/
public class OrderLineItem {
private String id;
private double lineItemPrice;
private String description;
private Order order; /**
* Default constructor
*/
public OrderLineItem() {
super();
} /**
* Note: unsaved-value An identifier property value that indicates that an instance
* is newly instantiated (unsaved), distinguishing it from transient instances that
* were saved or loaded in a previous session. If not specified you will get an exception like this:
* another object associated with the session has the same identifier
*
* @hibernate.id generator-class="native" type="int" column="OrderLineItem_ID" unsaved-value="0"
* @return int
*/
public String getId() {
return id;
}
/**
* @hibernate.many-to-one column="Order_ID" class="com.meagle.bo.Order"
*
* @return Order
*
*/
public Order getOrder() {
return order;
} /**
* @hibernate.property name="description" column="Description" type="string" not-null="false" unique="false"
*
* @return String
*/
public String getDescription() {
return description;
} /**
* @hibernate.property name="lineItemPrice" column="LineItemPrice" type="double" not-null="false" unique="false"
*
* @return double
*/
public double getLineItemPrice() {
return lineItemPrice;
} /**
* @param string
*/
public void setDescription(String string) {
description = string;
} /**
* @param i
*/
public void setId(String i) {
id = i;
} /**
* @param d
*/
public void setLineItemPrice(double d) {
lineItemPrice = d;
} /**
* @param order
*/
public void setOrder(Order order) {
this.order = order;
}}
<?xml version="1.0"?><!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"><hibernate-mapping>
<class
name="com.meagle.bo.Order"
table="Orders"
dynamic-update="false"
dynamic-insert="false"
> <id
name="id"
column="Order_ID"
type="String"
unsaved-value="0"
>
<generator class="uuid.hex">
</generator>
</id> <set
name="orderLineItems"
table="OrderLineItem"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
> <key
column="Order_ID"
/> <one-to-many
class="com.meagle.bo.OrderLineItem"
/>
</set> <property
name="userName"
type="string"
update="true"
insert="true"
column="UserName"
not-null="true"
unique="false"
/> <property
name="total"
type="double"
update="true"
insert="true"
column="Total"
not-null="false"
unique="false"
/> <!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Order.xml
containing the additional properties and place it in your merge dir.
--> </class></hibernate-mapping>
-----------------------------------------------------------------------
OrderLineItem.hbm.xml
<?xml version="1.0"?><!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"><hibernate-mapping>
<class
name="com.meagle.bo.OrderLineItem"
table="OrderLineItem"
dynamic-update="false"
dynamic-insert="false"
> <id
name="id"
column="OrderLineItem_ID"
type="String"
unsaved-value="0"
>
<generator class="uuid.hex">
</generator>
</id> <many-to-one
name="order"
class="com.meagle.bo.Order"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="Order_ID"
/> <property
name="description"
type="string"
update="true"
insert="true"
column="Description"
not-null="false"
unique="false"
/> <property
name="lineItemPrice"
type="double"
update="true"
insert="true"
column="LineItemPrice"
not-null="false"
unique="false"
/> <!--
To add non XDoclet property mappings, create a file named
hibernate-properties-OrderLineItem.xml
containing the additional properties and place it in your merge dir.
--> </class></hibernate-mapping>
*Cause: The specified sequence does not exist, or the user does
not have the required privilege to perform this operation.
*Action: Make sure the sequence name is correct, and that you have
the right to perform the desired operation on this sequence.检查一下用户是不是有权限使用这个sequence。
用sysdba连上后 select * from dba_sequences where SEQUENCE_NAME='序列名称' 看看有没有这个sequence
改成
unsaved-value=null
看看