Original Message
Subject:Inheritance problem(migrate from 1.0.3 to 1.0.4)
Date: Thu, 12 Oct 2006 17:47:31 +0800
From: Ohara Su [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Hi
I can not find the way to join mail list.
Please forward it to the mail list.
I read http://db.apache.org/ojb/docu/guides/advanced-technique.html
http://db.apache.org/ojb/docu/guides/advanced-technique.html
and I use Mapping Inheritance Hierarchies/Table Per Subclass via Foreign
Key.
My java class are list below.
When I call PB API to store DriverDownloadLog, I got errors in ojb 1.0.4
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl ] ERROR:
* SQLException during execution of sql-statement:
* sql statement was 'INSERT INTO DriverDownloadLog
(id,fileTile,fileName,fileSize,driverID,UserActionLogID) VALUES
(?,?,?,?,?,?) '
* Exception message is [ORA-02291: integrity constraint (
SVTS.DRIVERDOWNLOADLOG_FK_1) violated - parent key not found
]
* Vendor error code [2291]
* SQL state code [23000=INTEGRITY CONSTRAINT VIOLATION]
* Target class is 'com.via.sv.domain.DriverDownloadLog'
* PK of the target object is [id=520]
* Source object: [EMAIL PROTECTED]
* The root stack trace is --
* java.sql.SQLException: ORA-02291: integrity constraint
(SVTS.DRIVERDOWNLOADLOG_FK_1) violated - parent key not found
and p6spy shows
UPDATE OJB_HL_SEQ SET MAX_KEY='520',GRAB_SIZE='1',VERSION='520' WHERE
TABLENAME = 'SEQ_UserActionLog' AND VERSION = '519'
UPDATE OJB_HL_SEQ SET MAX_KEY='519',GRAB_SIZE='1',VERSION='519' WHERE
TABLENAME = 'SEQ_UserActionLog' AND VERSION = '518'
INSERT INTO UserActionLog
(id,machineIP,actionName,actionDate,actionDescription,userAccount)
VALUES ('519','127.0.0.1 http://127.0.0.1','Download
Driver','2006-10-12 17:16:06.875','Download Driver','creator')
INSERT INTO DriverDownloadLog
(id,fileTile,fileName,fileSize,driverID,UserActionLogID) VALUES
('520','Bug Report','borg.jpg','258041','80','0')
It seems that child class can not get the parent's key.
but it works fine in ojb 1.0.3
I don't know why there are errors in 1.0.4
Is it a bug for 1.0.4 ?
Or I made something wrong ?
===
/**
* @ojb.class
* table = UserActionLog
* include-inherited = false
* determine-extents = false
* @ojb.field
* name = userAccount
* length = 254
* jdbc-type = VARCHAR
*/
public class UserActionLog implements Serializable {
/**
* @ojb.field
* id=1
* autoincrement=ojb
* jdbc-type=INTEGER
* primarykey=true
*/
private int id;
/**
* @ojb.field
* id = 2
* length = 254
* jdbc-type = VARCHAR
*/
private String machineIP;
/**
* @ojb.field
* id = 3
* length = 254
* jdbc-type = VARCHAR
*/
private String actionName;
/**
* @ojb.field
* id = 4
* conversion =
org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimestampFieldConversion
* jdbc-type = TIMESTAMP
* nullable = true
*/
private Date actionDate;
/**
* @ojb.field
* id = 5
* length = 254
* jdbc-type = VARCHAR
*/
private String actionDescription;
/**
* @ojb.reference
* auto-retrieve = true
* foreignkey = userAccount
* auto-update = link
* auto-delete = none
* class-ref = VIAUser
* proxy = false
*/
private VIAUser actor;
/**
* @ojb.class
* table = DriverDownloadLog
* include-inherited = false
* @ojb.field
* name = UserActionLogID
* jdbc-type = INTEGER
* @ojb.reference class-ref=UserActionLog
* auto-retrieve=true
* auto-update=object
* auto-delete=object
* foreignkey=UserActionLogID
*/
public class DriverDownloadLog extends UserActionLog {
/**
* @ojb.field
* id=1
* autoincrement=ojb
* jdbc-type=INTEGER
* primarykey=true
*/
private int id;
/**
* @ojb.field
* id = 2
* length = 254
* jdbc-type = VARCHAR
*/
private String fileTile;
/**
* @ojb.field
* id = 3
* length = 254
* jdbc-type = VARCHAR
*/
private String fileName;
/**
* @ojb.field
* id=4
* jdbc-type=BIGINT
*/
private long fileSize;
/**
* @ojb.field
* id=5
* jdbc-type=INTEGER
* nullable = false
*/
private int driverID;
DriverDownloadLog downloadLog = new DriverDownloadLog();
downloadLog.setActor(viaUser);
downloadLog.setMachineIP(ip);
downloadLog.setActionDate(new java.util.Date());
downloadLog.setActionDescription(Download Driver);
downloadLog.setActionName(Download Driver);