SOS?求教執行CMP之create,能正常執行,但資料庫中無資料

dlpww發表於2003-10-15
在JBOSS3環境下,呼叫CMP實體之create新增資料,正常執行,但表中未有資料增加,已折騰我N天,急求教?
ProductBeanTestClient1 client = new ProductBeanTestClient1();
try {


client.create("-893", "SD-64", "64 MB SDRAM", 50);
Iterator i = client.findByName("SD-64").iterator();
System.out.println("These products match the name SD-64:");
while (i.hasNext()) {
Product prod = (Product) PortableRemoteObject.narrow(i.next(), Product.class);
System.out.println(prod.getDescription());
}
}
catch (Exception e) {
e.printStackTrace();
}

myproject2.ProductBeanTestClient1
以下是在Jbuilder8下第一次執行的情況,正常執行(資料庫sql server2000),但表中沒有增加資料據,透過sql profiler未檢測到發向sql server的sql語句。

-- Initializing bean access.-- Succeeded initializing local bean access through Local Home interface.-- Execution time: 2164 ms.-- Calling create(-891, P5-400, 400 Mhz Pentium, 300.0)-- Succeeded: create(-891, P5-400, 400 Mhz Pentium, 300.0)-- Execution time: 40 ms.-- Return value from create(-891, P5-400, 400 Mhz Pentium, 300.0): ProductBeanRemote:myproject2.Product ...-- Calling findByName(SD-64)-- Succeeded: findByName(SD-64)-- Execution time: 40 ms.-- Return value from findByName(SD-64): [].These products match the name SD-64:

以下是在Jbuilder8下第二次執行同樣程式碼的情況,出錯(資料庫sql server2000),主鍵異常。
-- Calling create(-895, SD-256, 256 MB SDRAM, 200.0)javax.ejb.DuplicateKeyException: Entity with primary key myproject2.ProductPK@154e07 already exists at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:128) at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:527) at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:253)-- Failed: create(-895, SD-256, 256 MB SDRAM, 200.0) 。。。-- Return value from create(-895, SD-256, 256 MB SDRAM, 200.0): null.-- Calling findByName(SD-64)-- Succeeded: findByName(SD-64)-- Execution time: 130 ms.-- Return value from findByName(SD-64): [].These products match the name SD-64:


create table productbean(
productID varchar(60) not null primary key,
name varchar(60),
description varchar(200),
basePrice numeric(8,2) default 0.00
);

相關文章