Re: OQL Query Help

2004-04-09 Thread Philippe Hacquin
Hi,

here is the query:

OQLQuery query = odmg.newOQLQuery();
query.create(select aList from 
+ Book.class.getName()
+  where image.height  $1);
query.bind(new Integer(150));
List bookList = (List) query.execute();
There is a 1:1 association between Book and Image, nothing from a real 
app, that is just a test.

I didn't take time to check OJB JUnit's test, but I'm pretty sure there 
are some like this one.

Wil Hunt wrote:
What was the syntax for your query?  I presume that something about the
query triggered the join code.
Wil

Philippe Hacquin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi again,

sorry for the wrong tip. If it can be of any help, I've got such a query
working with MySQL 4.0.13 (an Integer as criteria, though, not a Date).


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


Where are the javadoc for reversedb2???

2004-04-09 Thread Sven Alisch
Hello ML,

I found some months ago the javadoc for reversedb2. I need this, because I 
want to create a command line tool for db-reverse engineering. But now, I 
can't find the documentation again. Is it intention? Is it closed? If not, 
please developer, be so kind to send me a link, where I can find the 
documentation.

Thanks,
Sven


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



Problems saving a m:n relationship

2004-04-09 Thread Stijn de Witt
Hi,

I have a problem trying to persist two objects that are related through an indirection 
table. This is what my tables look like:

-
PERSON
id
firstname
lastname
...

ADDRESS
id
street
housenr
...

PERSON_ADDRESS
person_id
address_id
-


I have chosen for this construction, because COMPANY can have multiple addresses too, 
so I don't want a column person_id in ADDRESS. One address doesn't have to be 
available for multiple PERSON's or COMPANY's or whatever, so it actually is more of a 
1:n relationship using an indirection table. So PERSON_ADDRESS will often contain the 
same person_id multiple times, but not the same address_id.
I've read the tutorials, but I don't get it to work. I'll show (a fragment of) our 
repository_user.xml:


-
class-descriptor
class=nl.bergland.codamo.Address
table=bit_Address

field-descriptor
name=id
column=id
jdbc-type=INTEGER
primarykey=true
length=11

/field-descriptor
field-descriptor
name=street
column=street
jdbc-type=VARCHAR
length=64

/field-descriptor
field-descriptor
name=houseNr
column=houseNr
jdbc-type=VARCHAR
length=16

/field-descriptor
/class-descriptor

class-descriptor
class=nl.bergland.codamo.Person
table=bit_Person

field-descriptor
name=id
column=id
jdbc-type=INTEGER
primarykey=true
length=11

/field-descriptor
field-descriptor
name=firstName
column=firstName
jdbc-type=VARCHAR
length=24

/field-descriptor
field-descriptor
name=lastName
column=lastName
jdbc-type=VARCHAR
length=24

/field-descriptor
collection-descriptor
name=addresses
element-class-ref=nl.bergland.codamo.Address
indirection-table=bit_PersonAddress
auto-retrieve=true
auto-update=true
auto-delete=true

fk-pointing-to-this-class column=personId/
fk-pointing-to-element-class column=addressId/
/collection-descriptor
/class-descriptor
-


The generated tables in mysql seem to be ok with me (we actually use OjbDoclet to 
generate the repository.xml and the SQL) and insertion of a PERSON works fine. 
However, when we create a new person, add a new Address to it and try to save the 
person, the following happens:

A new record gets created for PERSON fine
A new record gets created for ADDRESS fine, but when I set auto-update to true, 2 get 
created??
A new record gets created for PERSON_ADDRESS, but both the columns person_id and 
address_id are set to 0.

Our save code looks something like this:


-
Person person = new Person;
person.getAddresses().add(new Address());

Implementation impl = OJB.getInstance();
Database db = impl.newDatabase();

db.open(default, Database.OPEN_READ_WRITE);
Transaction tx = impl.newTransaction();
tx.begin();

// establish database locks on all root dataobjects
tx.lock(person, Transaction.WRITE);


// set person and address values
// ...

tx.commit();
db.close();
-


A lot of info for a first-time post, I hope this problem sounds familiar to someone 
here.
Thanks,

-Stijn



Re: Where are the javadoc for reversedb2???

2004-04-09 Thread Armin Waibel
Hi Sven,

Sven Alisch wrote:

Hello ML,

I found some months ago the javadoc for reversedb2. I need this, because I 
want to create a command line tool for db-reverse engineering.
Cool, will it be open-source?

But now, I 
can't find the documentation again. Is it intention? Is it closed?
Currently no one is working on that stuff.
If you use the source version of OJB call
ant javadoc

this ant target will create all OJB javadoc to directory 
[db-OJB]/target/doc/javadoc

regards,
Armin
If not, 
please developer, be so kind to send me a link, where I can find the 
documentation.

Thanks,
Sven
-
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: Where are the javadoc for reversedb2???

2004-04-09 Thread Sven Alisch
Hi Armin,

 Cool, will it be open-source?

OF COURSE YES Everything I program (most in C++/Qt) is free and open 
sourced! In my opinion it is a desaster to use your great framework for a 
closed commercial project. This knowledge must be free. :-)

 ant javadoc

Thank you. Why did I not come to the idea by scanning your makefile tsts ... 
:-)

 this ant target will create all OJB javadoc to directory
 [db-OJB]/target/doc/javadoc

OK.

greetings from potsdam (germany),
Sven


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



Re: Problem with SequenceManagerNativeImpl and MySql

2004-04-09 Thread Mike Ahlers
Hi Armin,

Thanks! That indeed solved the problem! Reply-posted this on user-list 
for community :)
And no, the hippo is just fine!

- Mike

Armin Waibel wrote:

Hi Mike,

I think you don't have specified the correct database in your 
jdbc-connection-descriptor:

jdbc-connection-descriptor
   jcd-alias=default
   default-connection=true
==!!platform=Hsqldb
   jdbc-level=2.0
...
The platform attribute should be platform=MySQL in your case. This 
enable OJB to use the right platform class.
see http://db.apache.org/ojb/platforms.html
and http://db.apache.org/ojb/repository.html#jdbc-connection-descriptor
for more info.

 during SequenceManager.afterStore (for a nl.hippo.nvpt.Articles):
 Syntax
 error or access
or maybe OJB can't store the hippo ;-)

By the way, please use the user-list for these kinds of problems to 
make it possible for other user to benefit/learn.

regards,
Armin
Mike Ahlers wrote:

Hi,

I am using rc6 and MySQL (4.0.18-nt) database. All I want is to have 
the primary key after a store (for new object), the database uses 
auto-increment, and I am experimenting with several SequenceManagers.

The SequenceManagerInMemoryImpl works, however not suitable for 
multiple instances will work on the database. The documentation says 
I should use a special Manager because of MySQL and therefore I am 
using SequenceManagerNativeImpl. This works partially, as in, it 
generates negative primary keys (and not unique), but when I am 
setting access=readonly in my reposity for field-descriptor I 
receive the following error:

[org.apache.ojb.broker.core.PersistenceBrokerImpl] ERROR: 
SQLException during SequenceManager.afterStore (for a 
nl.hippo.nvpt.Articles): Syntax error or access
violation,  message from server: You have an error in your SQL 
syntax.  Check the manual that corresponds to your MySQL server 
version for the right syntax to use near 'CALL IDENTITY()' at line 1
Syntax error or access violation,  message from server: You have an 
error in your SQL syntax.  Check the manual that corresponds to your 
MySQL server version for the right syntax to use near 'CALL 
IDENTITY()' at line 1 java.sql.SQLException: Syntax error or access 
violation,  message from server: 
You have an error in your SQL syntax.  Check the manual that 
corresponds to your MySQL server version for the right syntax to use 
near 'CALL IDENTITY()' at line 1
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1876)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
   at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1153)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:2048)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:2005)
   at com.mysql.jdbc.Statement.executeQuery(Statement.java:1156)
   at 
org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl.getLastInsert(SequenceManagerNativeImpl.java:263) 

   at 
org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl.afterStore(SequenceManagerNativeImpl.java:155) 

   at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBrokerImpl.java:1465) 

   at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1378) 

   at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:730) 

   at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:165) 

   at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:165) 

Current setup:
--- start snippet ---
sequence-manager 
className=org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl 

   attribute attribute-name=grabSize attribute-value=10/
/sequence-manager
class-descriptor class=nl.hippo.nvpt.Articles table=ARTICLES
   field-descriptor name=id primarykey=true 
autoincrement=true access=readonly nullable=false 
default-fetch=true column=ID jdbc-type=INTEGER/
   
--- end snippet ---

What am I missing here? Or are there other solutions?

Thanks in advance,
Mike Ahlers
-
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: Problems saving a m:n relationship

2004-04-09 Thread Armin Waibel
Hi Stijn,

a few days ago I wrote some tests for M:N handling in odmg-api and 
stumble across the same problem (hope we can fix this soon). There are 
two possible workarounds:

Transaction tx = odmg.newTransaction();
tx.begin();
Iterator it = person.getAddresses().iterator();
while(it.hasNext())
{
   database.makePersistent(it.next());
}
database.makePersistent(person);
tx.commit();
or you can use the pb-api to insert your object (this looks a little bit 
complex, because you have to set auto-update/delete false when using 
odmg-api):

TransactionExt tx = (TransactionExt) odmg.newTransaction();
tx.begin();
PersistenceBroker pb = tx.getBroker();
Iterator it = person.getAddresses().iterator();
while(it.hasNext())
{
   pb.store(it.next());
}
pb.store(person);
pb.serviceBrokerHelper().link(person, true);
tx.commit();
Hope this will help you.

regards,
Armin
Stijn de Witt wrote:

Hi,

I have a problem trying to persist two objects that are related through an indirection table. This is what my tables look like:

-
PERSON
id
firstname
lastname
...
ADDRESS
id
street
housenr
...
PERSON_ADDRESS
person_id
address_id
-
I have chosen for this construction, because COMPANY can have multiple addresses 
too, so I don't want a column person_id in ADDRESS. One address doesn't have to be 
available for multiple PERSON's or COMPANY's or whatever, so it actually is more of a 
1:n relationship using an indirection table. So PERSON_ADDRESS will often contain the 
same person_id multiple times, but not the same address_id.
I've read the tutorials, but I don't get it to work. I'll show (a fragment of) our 
repository_user.xml:
-
class-descriptor
class=nl.bergland.codamo.Address
table=bit_Address
field-descriptor
name=id
column=id
jdbc-type=INTEGER
primarykey=true
length=11

/field-descriptor
field-descriptor
name=street
column=street
jdbc-type=VARCHAR
length=64

/field-descriptor
field-descriptor
name=houseNr
column=houseNr
jdbc-type=VARCHAR
length=16

/field-descriptor
/class-descriptor
class-descriptor
class=nl.bergland.codamo.Person
table=bit_Person
field-descriptor
name=id
column=id
jdbc-type=INTEGER
primarykey=true
length=11

/field-descriptor
field-descriptor
name=firstName
column=firstName
jdbc-type=VARCHAR
length=24

/field-descriptor
field-descriptor
name=lastName
column=lastName
jdbc-type=VARCHAR
length=24

/field-descriptor
collection-descriptor
name=addresses
element-class-ref=nl.bergland.codamo.Address
indirection-table=bit_PersonAddress
auto-retrieve=true
auto-update=true
auto-delete=true

fk-pointing-to-this-class column=personId/
fk-pointing-to-element-class column=addressId/
/collection-descriptor
/class-descriptor
-
The generated tables in mysql seem to be ok with me (we actually use OjbDoclet to generate the repository.xml and the SQL) and insertion of a PERSON works fine. However, when we create a new person, add a new Address to it and try to save the person, the following happens:

A new record gets created for PERSON fine
A new record gets created for ADDRESS fine, but when I set auto-update to true, 2 get 
created??
A new record gets created for PERSON_ADDRESS, but both the columns person_id and 
address_id are set to 0.
Our save code looks something like this:

-
Person person = new Person;
person.getAddresses().add(new Address());
Implementation impl = OJB.getInstance();
Database db = impl.newDatabase();

db.open(default, Database.OPEN_READ_WRITE);
Transaction tx = impl.newTransaction();
tx.begin();

// establish database locks on all root dataobjects
tx.lock(person, Transaction.WRITE);


// set person and address values
// ...

tx.commit();
db.close();
-

A lot of info for a first-time post, I hope this problem sounds familiar to 
someone here.
Thanks,
-Stijn


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


Re: Problems saving a m:n relationship

2004-04-09 Thread Stijn de Witt
Hi Armin,

Thanks for your helpful response!
So if i understand you correctly, OJB's ODMG implementation, at the moment
doesn't support fully transparent m:n relations, but it might in the future?

The workarounds you showed look ok to me, but I have another question. In
the tutorials, the PersistenceBroker API is used for the m:n relationships.
OJB also offers JDO support (through a plugin, native later). Could you
advise me on the API to use? We were planning on using ODMG because it's
'official', but we don't have enough know-how to make a really informed
decision.
If you were planning on building a lare portal based on Jetspeed using OJB,
what persistence api would you choose? Am I right in thinking that the
PersistenceBroker API is the most feature-rich?  The official site somehow
conveys that to me...

Thanks for your answer and I'll try your workarounds immediately!

-Stijn


- Original Message - 
From: Armin Waibel [EMAIL PROTECTED]
To: OJB Users List [EMAIL PROTECTED]
Sent: Friday, April 09, 2004 2:00 PM
Subject: Re: Problems saving a m:n relationship


 Hi Stijn,

 a few days ago I wrote some tests for M:N handling in odmg-api and
 stumble across the same problem (hope we can fix this soon). There are
 two possible workarounds:

 Transaction tx = odmg.newTransaction();
 tx.begin();
 Iterator it = person.getAddresses().iterator();
 while(it.hasNext())
 {
 database.makePersistent(it.next());
 }
 database.makePersistent(person);
 tx.commit();

 or you can use the pb-api to insert your object (this looks a little bit
 complex, because you have to set auto-update/delete false when using
 odmg-api):

 TransactionExt tx = (TransactionExt) odmg.newTransaction();
 tx.begin();
 PersistenceBroker pb = tx.getBroker();
 Iterator it = person.getAddresses().iterator();
 while(it.hasNext())
 {
 pb.store(it.next());
 }
 pb.store(person);
 pb.serviceBrokerHelper().link(person, true);
 tx.commit();

 Hope this will help you.

 regards,
 Armin

 Stijn de Witt wrote:

  Hi,
 
  I have a problem trying to persist two objects that are related through
an indirection table. This is what my tables look like:
 
  -
  PERSON
  id
  firstname
  lastname
  ...
 
  ADDRESS
  id
  street
  housenr
  ...
 
  PERSON_ADDRESS
  person_id
  address_id
  -
 
 
  I have chosen for this construction, because COMPANY can have multiple
addresses too, so I don't want a column person_id in ADDRESS. One address
doesn't have to be available for multiple PERSON's or COMPANY's or whatever,
so it actually is more of a 1:n relationship using an indirection table. So
PERSON_ADDRESS will often contain the same person_id multiple times, but not
the same address_id.
  I've read the tutorials, but I don't get it to work. I'll show (a
fragment of) our repository_user.xml:
 
 
  -
  class-descriptor
  class=nl.bergland.codamo.Address
  table=bit_Address
 
  field-descriptor
  name=id
  column=id
  jdbc-type=INTEGER
  primarykey=true
  length=11
  
  /field-descriptor
  field-descriptor
  name=street
  column=street
  jdbc-type=VARCHAR
  length=64
  
  /field-descriptor
  field-descriptor
  name=houseNr
  column=houseNr
  jdbc-type=VARCHAR
  length=16
  
  /field-descriptor
  /class-descriptor
 
  class-descriptor
  class=nl.bergland.codamo.Person
  table=bit_Person
 
  field-descriptor
  name=id
  column=id
  jdbc-type=INTEGER
  primarykey=true
  length=11
  
  /field-descriptor
  field-descriptor
  name=firstName
  column=firstName
  jdbc-type=VARCHAR
  length=24
  
  /field-descriptor
  field-descriptor
  name=lastName
  column=lastName
  jdbc-type=VARCHAR
  length=24
  
  /field-descriptor
  collection-descriptor
  name=addresses
  element-class-ref=nl.bergland.codamo.Address
  indirection-table=bit_PersonAddress
  auto-retrieve=true
  auto-update=true
  auto-delete=true
  
  fk-pointing-to-this-class column=personId/
  fk-pointing-to-element-class column=addressId/
  /collection-descriptor
  /class-descriptor
  -
 
 
  The generated tables in mysql seem to be ok with me (we actually use
OjbDoclet to generate the repository.xml and the SQL) and insertion of a
PERSON works fine. However, when we create a new person, add a new Address
to it and try to save the person, the following happens:
 
  A new record gets created for PERSON fine
  A new record gets created for ADDRESS fine, but when I set auto-update
to true, 2 get created??
  A new record gets created for PERSON_ADDRESS, but both the columns
person_id and address_id are set to 0.
 
  Our save code looks something like this:
 
 
  -
  Person person = new Person;
  

2nd REPOST:OJB:Dynamic association and Colored graph

2004-04-09 Thread Ajitesh Das
All: 
I have a design question. 
Let me first describe the problem: 
I like to store, update, delete, and retrieve a graph where the nodes 
are colored differently - for e.g. red, blue, yellow, green, black, etc. 
etc. 
[A new color could be added in future] 
The graph will be constructed at runtime. 
My object node: 
 Node: { p1,p2,p3, Edges[]} 
 Blue_Node extends Node : { p4,p5,p6} 
 Red_Node extends Node: {p7,p8,p9} 
  :: 
 And so on... 

Where pi = property i 
  and pi != pj for any i and j 

During the runtime, based on input data stream, I will construct and 
store: 
Edge[Node(a) - Node(b),wi] where wi is a weight value 
on the Edge[Node(a)-Node(b)] 
   Node(a) could be blue, red, yellow, green ...color 
   Node(b) could be blue, red, yellow, green ...color 
And also there can co-exist an Edge[Node(a)-Node(b), wj] where wi != wj 
  
I am trying to model this data structure in term of 1:n mapping table. 
Is this possible model with the following way: 
collection-descriptor 
 name=allNodesInGroup 
 element-class-ref=com.acme.graph.Node 
 orderby=colorId 
 sort=DESC 
   
 inverse-foreignkey field-ref=nodeId/ 
  /collection-descriptor 
and can I also use the fault or proxy object ? 

Or 

I have to deal this manually using : 
public void link(Object obj, boolean insert) 
public void unlink(Object obj) 
public boolean link(Object obj, String attributeName, boolean 
insert) 
public boolean unlink(Object obj, String attributeName) 

Thanks in advance for your help 
Regards 
  Ajitesh