inherit problem

2004-05-03 Thread Carles Duque
Hello!!
 
I have a problem witth retrieve two classes in a two tables.
Classes: A and B. B estends A.
 
When I have one class (example: A) I see if Id (getId()) is null. If its true, I do 
select MAX and I assing to class (setId()). This work ok, always.
In the new case (A and B), when I retrieve a class B, I do select MAX, assign id, 
but returns SQLException, because ID is null.
 
Is possible that if you put auto-retrieve=true, you must use auto-increment?? Its 
possible another solution?
 
Thanks!!!
 
 
Carles


RE: inherit problem

2004-05-03 Thread Carles Duque
My repository.xml has this lines as new

In class descriptor of A:
extent-class class-ref=x.B /

In class descriptor of B:
reference-descriptor name=super class-ref=x.A
auto-retrieve=true
auto-update=true
auto-delete=true

foreignkey field-ref=idB /
/reference-descriptor


This is correct, isn't it?

Carles






-Mensaje original-
De: Stefan Schlösser [mailto:[EMAIL PROTECTED]
Enviado el: lunes, 03 de mayo de 2004 12:52
Para: OJB Users List
Asunto: Re: inherit problem


Hi,

auto-retrieve does not require auto-increment to be set.

You likely made a misstake in your class-definitions and or repository 
declarations.

Stefan

Carles Duque wrote:

 Hello!!
  
 I have a problem witth retrieve two classes in a two tables.
 Classes: A and B. B estends A.
  
 When I have one class (example: A) I see if Id (getId()) is null. If its true, I do 
 select MAX and I assing to class (setId()). This work ok, always.
 In the new case (A and B), when I retrieve a class B, I do select MAX, assign id, 
 but returns SQLException, because ID is null.
  
 Is possible that if you put auto-retrieve=true, you must use auto-increment?? Its 
 possible another solution?
  
 Thanks!!!
  
  
 Carles
 



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



Problem with boolean

2004-05-03 Thread Carles Duque
Hi!!!
I try to mapping a boolean field in oracle.
I have put in field-descriptor: jdbc-type=BIT
the field in DB is NUMBER(1)
the attributte in class is boolean.
I use a fieldconversion: 
conversion=org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion 
in the field-descriptor.
 
The error when I execute a collection query:
 
Original Exception: java.lang.NullPointerException 
at org.apache.ojb.jdori.sql.OjbFieldManager.getValue(OjbFieldManager.java:308) 
at 
org.apache.ojb.jdori.sql.OjbFieldManager.fetchBooleanField(OjbFieldManager.java:113) 
at com.sun.jdori.common.state.StateManagerImpl.replacingBooleanField(Unknown Source) 
at borsatreball.fielding.Camp.jdoReplaceField(Unknown Source) 
at borsatreball.fielding.Data.jdoReplaceField(Unknown Source) 
at borsatreball.fielding.Camp.jdoReplaceFields(Unknown Source) 
at com.sun.jdori.common.state.StateManagerImpl.replaceFields(Unknown Source) 
at org.apache.ojb.jdori.sql.OjbExtent.provideStateManagers(OjbExtent.java:178) 
at org.apache.ojb.jdori.sql.OjbExtent.init(OjbExtent.java:101) 
at org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(OjbStoreManager.java:251) 
at com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown Source) 
at com.sun.jdori.common.query.QueryImpl.checkCandidates(Unknown Source) 
at com.sun.jdori.common.query.QueryImpl.execute(Unknown Source) 

 
Can you help me?? Thanks!!


Select MAX

2004-04-14 Thread Carles Duque
I have a problem with this type of select. This is my code:
**
Criteria crit =3D new Criteria();
org.apache.ojb.broker.query.ReportQueryByCriteria query =3D new =
ReportQueryByCriteria(Estudiant.class, crit);
query.setColumns(new String[] { MAX(ID) });
Iterator iter2 =3D broker.getReportQueryIteratorByQuery(query);
***

But I don't know how return this iter2.next(). An Object of nothing... =
because It generate ClassCastException with Estudiant, Long, Integer and =
Double.

Anyone Can help me? Thanks!!


Carles Duque

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



RE: Select MAX

2004-04-14 Thread Carles Duque
Thanks Wally, really good...
The final code:
**
Criteria crit = new Criteria();
org.apache.ojb.broker.query.ReportQueryByCriteria query = new 
ReportQueryByCriteria(Estudiant.class, crit);
query.setColumns(new String[] { MAX(ID) });
Iterator iter2 = broker.getReportQueryIteratorByQuery(query);
if (iter2.hasNext()){
 Object[] objs = (Object[]) iter2.next();
 Integer max = (Integer) objs[0];
 System.out.println(MAX:+max);
}
**
 
But I have another question... it's the best way to generate and ID for store new 
items??? Sequence is the best??
 
Thanks. Carles

-Mensaje original- 
De: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] 
Enviado el: mié 14/04/2004 15:40 
Para: OJB Users List 
CC: 
Asunto: RE: Select MAX



Hi Carles,

Report Queries return an Iterator of Object[]

Object[] objs = iter2.next();
Integer max = objs[0];

Hope this helps,

Wally

-Original Message-
From: Carles Duque [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 14, 2004 7:54 AM
To: [EMAIL PROTECTED]
Subject: Select MAX


I have a problem with this type of select. This is my code:
**
Criteria crit =3D new Criteria();
org.apache.ojb.broker.query.ReportQueryByCriteria query =3D new =
ReportQueryByCriteria(Estudiant.class, crit);
query.setColumns(new String[] { MAX(ID) });
Iterator iter2 =3D broker.getReportQueryIteratorByQuery(query);
***

But I don't know how return this iter2.next(). An Object of nothing... =
because It generate ClassCastException with Estudiant, Long, Integer and
=
Double.

Anyone Can help me? Thanks!!


Carles Duque

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





Logger Error

2004-03-18 Thread Carles Duque
Hello, I'm using tomcat and ojb. I test an example of cocoon with ojb:

PersistenceManager manager = factory.getPersistenceManager();
/* 2. Get current transaction */
Transaction tx = manager.currentTransaction();
/* 3. Start a Transaction */
tx.begin();
/* 4. now perform persistence operations. Store the new user */
manager.makePersistent(usr);
/* 5. Commit the transaction  */
  tx.commit();


In the tx.begin(); tha application throws an error like this:
[BOOT] ERROR: [org.apache.ojb.broker.util.logging.LoggerFactoryImpl]
Could not set logger for class null
org/apache/commons/lang/exception/NestableException
java.lang.NoClassDefFoundError:
org/apache/commons/lang/exception/NestableException
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:509)


Can you help me?

Carles



Logger error

2004-03-17 Thread Carles Duque
Hello, I'm using tomcat and ojb. I test an example of cocoon with ojb:

PersistenceManager manager = factory.getPersistenceManager();
/* 2. Get current transaction */
Transaction tx = manager.currentTransaction();
/* 3. Start a Transaction */
tx.begin();
/* 4. now perform persistence operations. Store the new user */
manager.makePersistent(usr);
/* 5. Commit the transaction  */
  tx.commit();


In the tx.begin(); tha application throws an error like this:
[BOOT] ERROR: [org.apache.ojb.broker.util.logging.LoggerFactoryImpl]
Could not set logger for class null
org/apache/commons/lang/exception/NestableException
java.lang.NoClassDefFoundError:
org/apache/commons/lang/exception/NestableException
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:509)


Can you help me?

Carles