RE: [FAQ] Re: Why select by insert?

2003-08-08 Thread Stephen Ting
Thomas,

Is there any equivalent features in ODMG api?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 08 August 2003 14:15
To: OJB Users List
Subject: [FAQ] Re: Why select by insert?


Hi,

pb.store(obj) must check if obj is already stored in the db or not to 
choose an UPDATE or an INSERT.
that check done with the select.

You can get rid of this additional select by using hints.
broker.store(obj,ObjectModificationDefaultImpl.INSERT) forces 
an INSERT.
broker.store(obj,ObjectModificationDefaultImpl.UPDATE) forces 
an UPDATE.


Thomas

lyl wrote:
 Thanks for oliver, but I just used PB.store()! I used p6spy on front 
 of Mysql Driver, there's one select statement preceding each insert 
 statement. I wonder what's for? Does this really necessary? Can I 
 disable that ?
 
 thanx


-
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:References Talking Smack

2003-08-08 Thread Terry Brick
Hi Laugusto,
Thanks for letting me know I'm not alone :)
Just curious... I reported two problems...
1) When using numeric wrapper classes OJB tries to
insert nulls in fk's if I don't do a
retrieveAllReferences() first.
2)  When I try to do a retrieveAllReferences()
first, it complains that the referenced class does not
have an autoincrement field.

Did you get #1, #2 or both?  I'm thinking that #1 and
#2 are unrelated.  In any case, I think #2 might have
something to do with...
org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl
If you have problem #2, do you use that sequence
manager?  If you don't then doing
retrieveAllReferences(obj) might work for you.

BTW:  Adding autoincrement=true to that problem
class seems to pacify it for now.  However, it does
seem to be a bug, and will probably come back to bite
me in the near future.

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



RE: JDO - Objects fetched from DB are in transient state, not persistent

2003-08-08 Thread Mahler Thomas
Hi Ketan,

 
 Thomas,
 
 I was wondering if you'd been able to determine the right way 
 to proceed 
 with this.  

I hope to fix the problem within the next 3 weeks.

 If I understood correctly before, the JDO layer is broken 
 and has been for some time.  But that can't be right, since 
 other people 
 are using JDO. 
It's not really broker. you can use it and insert and update objects. The
JDO tutorial application is running without problems!

The only problem seems to be that I did not manage to transfer the correct
state information during the retrieval of extents. Only if you rely on this
state information you'll get problems...

 Regardless, I hope you find the solution; 
 it's kind of 
 hard to use JDO when it's read-only :-).  Thanks.

it stays on my todo list untils it's fixed!

cheers,
Thomas

 
 
 Thomas Mahler wrote:
  Hi Ketan,
  
  Ketan Gangatirkar wrote:
  
 
  Thomas,
 
  I've been stepping through the OBJ JDO and JDORI code.  I have 
  determined that the PersistenceCapable objects never are 
 assigned a 
  StateManager (member jdoStateManager) when they are 
 assembled from a 
  row result.
  
  
  That's exactly the problem! I'm currently researching how 
 to solve this 
  issue.
  
   When an object is created and persisted, it does get assigned a 
  StateManager, but I see no corresponding assignment for objects 
  fetched from the DB.  
  
  
  I does does happen when objects are retrieved by Identity in 
  OjbStoreManager.fetch.
  
  But it does not happen when loading object via a query or a 
 whole Extent.
  
  I'm currently trying to implement the StateManager assignment  in 
  OjbExtent too. But it's not as easy as I hoped...
  
  I'll need a closer look at the JDORI again...
  
  cheers,
  Thomas
 
 
 -
 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]



Looks like we are on the right way :)

2003-08-08 Thread Antonio Gallardo
Hi OJBers:

I read this survey and want to share it with the community:

http://sdtimes.com/news/083/story5.htm

Best Regards,

Antonio Gallardo




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



Re: one table - multiple classes problem

2003-08-08 Thread Jakob Braeuchi
hi,

ojb fires a query for each extent (subclass)  residing in it's own 
table. extents in the same table (using ojbConcreteClass) are retrieved 
with one query.
this behaviour has the advantage that it runs on all dbms (an 
alternative would be to use UNION) !  on the other hand, we need 
multiple queries an we cannot  sort the whole result :(

hth
jakob
Crecente Casanova, David wrote:


  Hi,
  I don't know to do this task with only one query. I don't belive ojb can do it, but 
if you see the broker or query object in the API may be you find something.
  For storing you need 2 queries too. I don't know other way.
  
 

-Mensaje original-
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Enviado el: viernes, 08 de agosto de 2003 13:51
Para: OJB Users List
Asunto: RE: one table - multiple classes problem
Hi,

thanks for your answer. Correct me if i am wrong, but as far
as i can read you xml files, you need to run 2 queries to
get your 2 classes. I need to run 3 queries (actually there is one
more address, so i need to run 4 queries) to load all the data
i need from the database.  This should be no problem, but i am
wondering if it is not possible to do this in one step (1 query -
all 4 object will be loaded) ?
getting each object separately i have 4 db accesses instead of 1 !
just wondering,

Andreas 

 

  Hi,
  you can do it without problem.
  I have two classes for 
one table.

  Classes: Crm_cliente_masinfo, Crm_cliente_general
  Ta
ble: CRM_CLIENTE
(1)First xml descriptor.

!-- This repository file
is generated by the impart OJB Generator --
!--   www.impart.
ch [EMAIL PROTECTED]--
!--created at 9 Ju
l 2003 11:37:50 GMT --


class-descriptor 
 
class=com.indra.crm.vo.Crm_cliente_masinfo
 table=CRM_CLIENTE
   

 field-descriptor id=66
   name=ln_id_cliente
   column=
LN_ID_CLIENTE
   jdbc-type=INTEGER
   primarykey=true
	aut
oincrement=true
	sequence-name=sec_cliente
 /
 field-descr
iptor id=73
   name=ds_url
   column=DS_URL
   jdbc-typ
e=VARCHAR
 /
 field-descriptor id=74
   name=ts_coment
ario
   column=TS_COMENTARIO
   jdbc-type=VARCHAR
 /
 
field-descriptor id=79
   name=ln_facturacion
   column=LN
_FACTURACION
   jdbc-type=INTEGER
 /
 field-descriptor id=
80
   name=mn_nu_empleados
   column=MN_NU_EMPLEADOS
   j
dbc-type=INTEGER
 /
 field-descriptor id=81
   name=mn
_nu_fact_emp
   column=MN_NU_FACT_EMP
   jdbc-type=INTEGER
 /
 field-descriptor id=82
   name=sn_movil_emp
   colum
n=SN_MOVIL_EMP
   jdbc-type=INTEGER
 /
 field-descriptor 
id=83
   name=sn_nu_sedes
   column=SN_NU_SEDES
   jdbc
-type=INTEGER
 /
 field-descriptor id=84
   name=sn_nu
_sedes_hfc
   column=SN_NU_SEDES_HFC
   jdbc-type=INTEGER

/
 field-descriptor id=85
   name=ln_potencial_total
   
column=LN_POTENCIAL_TOTAL
   jdbc-type=INTEGER
 /
 field-
descriptor id=86
   name=ln_potencial_fijo
   column=LN_PO
TENCIAL_FIJO
   jdbc-type=INTEGER
 /
 field-descriptor id=
87
   name=ln_potencial_movil
   column=LN_POTENCIAL_MOVIL
   jdbc-type=INTEGER
 /
 field-descriptor id=88
   name=
ln_potencial_datos
   column=LN_POTENCIAL_DATOS
   jdbc-type=
INTEGER
 /
 field-descriptor id=89
   name=ln_potencial_
fijo_emp
   column=LN_POTENCIAL_FIJO_EMP
   jdbc-type=INTEGER

 /
 field-descriptor id=90
   name=ln_potencial_datos_em
p
   column=LN_POTENCIAL_DATOS_EMP
   jdbc-type=INTEGER
 /
   

 field-descriptor id=91
   name=ln_potencial_movil_emp
 
 column=LN_POTENCIAL_MOVIL_EMP
   jdbc-type=INTEGER
 /
 
field-descriptor id=92
   name=sn_id_usuario_alta
   column=
SN_ID_USUARIO_ALTA
   jdbc-type=INTEGER
 /
 field-descripto
r id=93
   name=dt_fh_alta
   column=DT_FH_ALTA
   jdbc
-type=TIMESTAMP
 /
 field-descriptor id=94
   name=sn_
id_usuario_mod
   column=SN_ID_USUARIO_MOD
   jdbc-type=INTEG
ER
 /
 field-descriptor id=95
   name=dt_fh_mod
   col
umn=DT_FH_MOD
   jdbc-type=TIMESTAMP
 /
 field-descriptor
id=96
   name=sn_id_usuario_baja
   column=SN_ID_USUARIO_
BAJA
   jdbc-type=INTEGER
 /
 field-descriptor id=97
 
 name=dt_fh_baja
   column=DT_FH_BAJA
   jdbc-type=TIMEST
AMP
 /

/class-descriptor

(2) Second xml descriptor

!-- 
This repository file is generated by the impart OJB Generator --
!--  
www.impart.ch [EMAIL PROTECTED]--
!--   
created at 9 Jul 2003 11:37:50 GMT --



c
lass-descriptor 
 class=com.indra.crm.vo.Crm_cliente_general
 tab
le=CRM_CLIENTE
   

 field-descriptor id=66
   name=ln_id_c
liente
   column=LN_ID_CLIENTE
   jdbc-type=INTEGER
   pri
marykey=true
autoincrement=true
sequence-name=sec_cliente
 /
 field-descriptor id=67
   name=ds_nb_cliente
   co
lumn=DS_NB_CLIENTE
   jdbc-type=VARCHAR
 /
 field-descrip
tor id=68
   name=ss_cif
   column=SS_CIF
   jdbc-type=
VARCHAR
 /
 field-descriptor id=69
   name=sn_lv_tipo_cl
iente
   column=SN_LV_TIPO_CLIENTE
   jdbc-type=INTEGER
 /
   

 field-descriptor id=70
   name=sn_lv_estado
   column=
SN_LV_ESTADO
   jdbc-type=INTEGER
 /
 

RE: RE : RE : BIGINT to Long, FieldConversion ?

2003-08-08 Thread Ricardo Tercero Lozano

You have to put the B instance. 

If there is a relation between the two classes in
repository.xml you must use object instances. 
Otherwise you must use the class A field id attribute.

Ricardo.



-Original Message-
From: Emmanuel Dupont [mailto:[EMAIL PROTECTED] 
Sent: viernes, 08 de agosto de 2003 18:56
To: 'OJB Users List'
Subject: RE : RE : BIGINT to Long, FieldConversion ?


Thanks Ricardo !

I would like to know wich kind of link you do :

Object A have a reference to B, called bB.

If I want to insert in db A, Have to do :

A.setbB(instanceB);

Or

A.setb_FK(id_B_PK);



Should I set the bB instance or the FK_Id ?

Because I seems that with small long I can do only setb_FK() and with bib
Long I have to set the B instance reference.



Thanks for your reply ...



-Message d'origine-
De : Ricardo Tercero Lozano [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi 8 août 2003 18:34
À : 'OJB Users List'
Objet : RE: RE : BIGINT to Long, FieldConversion ?

I use BIGINT for my primary keys and Long for class fields and everything
goes ok.


Ricardo.


-Original Message-
From: Emmanuel Dupont [mailto:[EMAIL PROTECTED] 
Sent: viernes, 08 de agosto de 2003 18:29
To: 'OJB Users List'
Subject: RE : BIGINT to Long, FieldConversion ?


More information : it faills on the FK key (not null column), null is put in
the assignReferenceFKs method from PersistenceBrokerImpl...

-Message d'origine-
De : Emmanuel Dupont [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi 8 août 2003 17:35
À : OJB Users List
Objet : BIGINT to Long, FieldConversion ?

All,

 

 

I would like to have a Long type in my jdo Object. But the jdbc mapping
tells that for a BIGINT it is a long (small).

 

So Could I use the Field conversion class ?

 

I try to use it with the Int2IntegerFieldConversion sample and I created a
long2LongFieldConversion.

 

But it doesn't work !

 

Any help would be really appreciated !

 



-
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]


-
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: JDO - Objects fetched from DB are in transient state, not persistent

2003-08-08 Thread Ketan Gangatirkar
Thomas,

I tried your suggestion.  I don't know how to interpret the results, 
though :-).  I changed the code fragment to:



PersistenceManagerFactory pmf = new OjbStorePMF();
PersistenceManager pm = pmf.getPersistenceManager();
PersistenceBrokerFactory.defaultPersistenceBroker().clearCache();
pm.currentTransaction().begin();
Extent extent = pm.getExtent(Building.class, false);
for (Iterator iterator = extent.iterator();
iterator.hasNext();)
{
Building b = (Building) iterator.next();
}
pm.currentTransaction().commit();

Building example = new Building();
example.setBuildingID(4);
Identity oid = new Identity(example);
pm.currentTransaction().begin();
Building building = (Building) pm.getObjectById(oid, false);



However, I am still getting the same exception:



javax.jdo.JDOUserException: Given object is not a valid OID.
FailedObject:org.lbjnow.calvin.location.Building{4}
NestedThrowables:
java.lang.IllegalArgumentException: arg1
	at com.sun.jdori.common.CacheManagerImpl.createNewSM(Unknown Source)
	at com.sun.jdori.common.CacheManagerImpl.getStateManager(Unknown Source)
	at com.sun.jdori.common.CacheManagerImpl.getObjectById(Unknown Source)
	at com.sun.jdori.common.PersistenceManagerImpl.getObjectById(Unknown 
Source)
	at com.sun.jdori.common.PersistenceManagerWrapper.getObjectById(Unknown 
Source)
	at org.apache.jsp.tj_jsp._jspService(tj_jsp.java:143)



I haven't had any problems using getObjectById() on objects that have 
just been persisted (consistent with the root problem), if I remember 
correctly.  Also, as before, when I iterate through the Extent, the 
objects all return false to jdoIsPersistent().  I also tried 
pm.getObjectById(new Identity(b)) from within the Extent iteration loop, 
which threw the same JDOUserException.

I can't tell if this is good news or bad; hopefully this gives you 
enough information to tell.  If nothing else, it's consistent!



Thomas Mahler wrote:

Hi Ketan,

Ketan Gangatirkar wrote:

Thomas,

I tried using the method in tutorial4 to look up objects by OID, but I 
kept getting javax.jdo.JDOUserException: Given object is not a valid 
OID.  This is the relevant code section, basically copied out of 
org.apache.ojb.tutorial5.UCEditProduct and adapted slightly:



PersistenceManagerFactory pmf = new OjbStorePMF();
PersistenceManager pm = pmf.getPersistenceManager();
Building example = new Building();
example.setBuildingID(4);
Identity oid = new Identity(example);
pm.currentTransaction().begin();
Building building = (Building) pm.getObjectById(oid, false);




Mhh, that's quite strange! that's the virtually the same code as in my 
UCEdit Example.
I definitely works with the Product class. Do you get the OJB JDO 
tutorial app running with the UCEdit usecase on your machine?

AFter looking clsoer at the JDORI I have an idea:
The problem could be caused because in my UCEdit the object to lookup is 
already in the JDORI cache. In your it is not and the cache wants to 
create a new SM, which then fails.

you could try to load the complete extent of your Building objects and 
iterate through it before calling your code fragment.
If it works, my assumption is correct, and I have even more work to do :-(

cheers,
Thomas
oid.toString() returns org.lbjnow.calvin.location.Building{4} which 
certainly looks plausible.

As a result, the work-around does not work :-/.  This happens with all 
my objects; I just picked the simplest to demonstrate.  The 
repository_user.xml section is:



class-descriptor class=org.lbjnow.calvin.location.Building
table=building
field-descriptor id=1 name=buildingID column=building_id
jdbc-type=INTEGER primarykey=true  autoincrement=true
sequence-name=building_id_seq /
field-descriptor id=2 name=shortName column=short_name
jdbc-type=VARCHAR/
field-descriptor id=3 name=longName column=long_name
jdbc-type=VARCHAR/
/class-descriptor


The part of the .jdo file for that class is:



class name=Building identity-type=application
objectid-class=java.lang.Integer
field name=buildingID primary-key=true
null-value=exception /
field name=shortName /
field name=longName /
/class


The class itself is rather simple right now, with just the fields 
listed above and the appropriate getter/setter methods.  The rest of 
the exception looks like this:



javax.jdo.JDOUserException: Given object is not a valid OID.
FailedObject:org.lbjnow.calvin.location.Building{4}
NestedThrowables:
java.lang.IllegalArgumentException: arg1
at com.sun.jdori.common.CacheManagerImpl.createNewSM(Unknown Source)
at com.sun.jdori.common.CacheManagerImpl.getStateManager(Unknown 
Source)
at com.sun.jdori.common.CacheManagerImpl.getObjectById(Unknown 
Source)
at 
com.sun.jdori.common.PersistenceManagerImpl.getObjectById(Unknown Source)
at 

Compile for JDK 1.3?

2003-08-08 Thread Daniel . B . Brown
I am following the quickstart.html directions and trying to run bin\build
junit using JDK 1.3.1.  It looks like a targeted effort was made to get
this work with JDKs other than 1.4.  However, the compile fails due to a
dependency on a JDK 1.4 class.  Is this a bug? or must we use JDK 1.4 or
better.

The stack trace is as follows:

C:\db-ojb-1.0.rc4bin\build junit
Buildfile: build.xml

splash:

set-archive-name:

set-archive-name-date:

detect-jdk:

check-jdk12proxy-classes:

check-jndi-classes:

use-jdk12:

use-jdk13:
 [echo] detected JDK 1.3

use-jdk14:

init:

prepare:
 [copy] Copying 586 files to C:\db-ojb-1.0.rc4\target\src
 [copy] Copying 259 files to C:\db-ojb-1.0.rc4\target\srctest
 [copy] Copying 10 files to C:\db-ojb-1.0.rc4\target\srcjca

check-j2ee-classes:

preprocess:
 [echo] using switches: +JDK13, -JDBC30
 [java]













.
 [java]





...

main:
[javac] Compiling 549 source files to C:\db-ojb-1.0.rc4\target\classes
[javac]
C:\db-ojb-1.0.rc4\target\src\org\apache\ojb\otm\copy\MetadataObjectC
opyStrategy.java:69: cannot resolve symbol
[javac] symbol  : class IdentityHashMap
[javac] location: package util
[javac] import java.util.IdentityHashMap;
[javac]  ^
[javac]
C:\db-ojb-1.0.rc4\target\src\org\apache\ojb\otm\copy\ReflectiveObjec
tCopyStrategy.java:68: cannot resolve symbol
[javac] symbol  : class IdentityHashMap
[javac] location: package util
[javac] import java.util.IdentityHashMap;
[javac]  ^
[javac]
C:\db-ojb-1.0.rc4\target\src\org\apache\ojb\otm\copy\MetadataObjectC
opyStrategy.java:100: cannot resolve symbol
[javac] symbol  : class IdentityHashMap
[javac] location: class
org.apache.ojb.otm.copy.MetadataObjectCopyStrategy
[javac] return clone(obj, new IdentityHashMap(), broker);
[javac]   ^
[javac]
C:\db-ojb-1.0.rc4\target\src\org\apache\ojb\otm\copy\ReflectiveObjec
tCopyStrategy.java:108: cannot resolve symbol
[javac] symbol  : class IdentityHashMap
[javac] location: class
org.apache.ojb.otm.copy.ReflectiveObjectCopyStrategy

[javac] return clone(toCopy, new IdentityHashMap(), new
HashMap(
));
[javac]  ^
[javac] 4 errors

BUILD FAILED
file:C:/db-ojb-1.0.rc4/build.xml:218: Compile failed; see the compiler error
out
put for details.

Total time: 1 minute 9 seconds


 __
 Daniel B. Brown | WELLS FARGO BANK MINNESOTA, N.A. |
 Software Architect | http://www.wellsfargo.com  | MAC N2702-011 | 
 9062 Old Annapolis Road | Columbia | MD | 21045-1951 | 
 p: 410.884.2034 | f: 410.715.2325 | [EMAIL PROTECTED]
 |
 

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



Re: Why not insert null?

2003-08-08 Thread Thomas Mahler
Hi,

I see only two reasons why OJB would write values into a timestamp column:
1. you have set the attribute locking=true in the field-descriptor
2. you are using a ConversionStrategy that modifies the column.
cheers,
Thomas
lyl wrote:
Thanks for ketan's response, but I don't think it is  caused by mysql, I
used p6spy , the spy.log indicate that the insert statement replace null
with current time. I think it is ojb who do that job.


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


M:N question

2003-08-08 Thread bian . xiaochun
Hello,
I have a emergent question.Here I have designed 3 tables:User 
Domain Role and I have 

   implemented User - Role M:N relation by add a table User_Role 
including the PK of table

   User  Role and write repository xml file(collection-descriptor,
fk-pointing-to-this-class

   fk-pointing-to-element-class).Now I want to add a column of PK of 
Domain in table 
 
   user_role,which means a user in a domain have a role,who can tell 
me how to implement it,

thanks a lot.