Re: store collections

2006-10-12 Thread Armin Waibel

Abid Hussain wrote:

Hi Armin,

How can it happen that you try to insert ojb-proxied objects? If the 
proxy object isn't materialized OJB assume that nothing has changed 
and skip the store.
Because I wanted to copy values from one database to another. So I first 
retrieved the values from the local DB and then tried to store them in 
the live-system DB.


But when the problem only comes up with proxied objects then it is all 
right, I then just let the object being materialized by using the 
debug()-method and then copy it.


If you call object.hashCode() the object should be materialized too.



Like Josef said, the code seems to be ok.



yep!

regards,
Armin


Thanks a lot for quick help.

Best regards,

Abid




Because, when I change the code to this:
public void storeAll(Collection valueObjects) {

if (valueObjects != null) {
broker.beginTransaction();
for (Iterator i = valueObjects.iterator(); i.hasNext();)
Object valueObject = i.next();
-- logger.debug(valueObject);
broker.store(valueObject, ObjectModification.INSERT);
}
broker.commitTransaction();
}
...it works because the object is loaded from the database when 
calling the debug()-method.
It seems that the broker has nothing to store in the method without 
the logging-statement seen below.


But is there any other way to solve this problem?

Regards,

Abid

Abid Hussain schrieb:

Hi everybody,

I want to implement a method which stores not only one object but a 
collection of objects.

I tried this one:
public void storeAll(Collection valueObjects) {

if (valueObjects != null) {
broker.beginTransaction();
for (Iterator i = valueObjects.iterator(); i.hasNext();)
Object valueObject = i.next();
broker.store(valueObject, ObjectModification.INSERT);
}
broker.commitTransaction();
}
...but it doesn't work, not one object is stored into the database.

Anybody got an idea?

Regards,

Abid





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ojb 1.x and number of ojb-users

2006-10-12 Thread Armin Waibel

Hi Abid,

Abid Hussain wrote:

Hello everybody,

I have two questions which do not concern about the usage of OJB:

1.
On the OJB-homepage it says that the work for OJB 1.x has started in 
11/2005 (http://db.apache.org/ojb/news.html).
I just wondered about this, because the last entry on the page is from 
12/2005. Are there any updates planned in the close future?




We are only a few active developer and during the past few months we
were concentrated on OJB 1.0.x, thus there was less progress on OJB
1.x/2.0 (and a few weeks ago I first had to merge changes from 1.0.x
with trunk).

The sources in OJB_1_0_RELEASE branch (pre 1.0.5) are stable, only a few
things had to be done (check compatibility with other databases and (if
needed) fix of database specific issues).



2.
Is there any reliable figures about how many people use OJB?
I'm just asking because when I talk to other developers about 
O/R-Mapping they mostly only know Hibernate and I wonder how OJB's 
standing is upon developers.




Sorry I don't have a OJB download statistic, but here you can find the
number of dev/user-list subscriber (scroll down)
http://people.apache.org/~coar/mlists#db.apache.org
Think this give an impression why a couple of developer don't know OJB
;-)
Seriously I think compared with Hibernate OJB is relatively unknown.

regards,
Armin


Regards,

Abid






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[Fwd: Inheritance problem(migrate from 1.0.3 to 1.0.4)]

2006-10-12 Thread Armin Waibel



 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);