objectbridge-developers Mailing List for ObJectRelationalBridge (Page 53)
Brought to you by:
thma
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(14) |
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(33) |
Feb
(8) |
Mar
(3) |
Apr
(1) |
May
(18) |
Jun
(6) |
Jul
(15) |
Aug
(71) |
Sep
(29) |
Oct
(43) |
Nov
(77) |
Dec
(54) |
2002 |
Jan
(54) |
Feb
(147) |
Mar
(144) |
Apr
(163) |
May
(307) |
Jun
(240) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: David F. <dw...@la...> - 2001-08-10 05:18:21
|
At 10:55 PM 8/9/2001, Dirk Olmes wrote: >David Forslund wrote: > > > > To illustrate things better I'll just give a short description of my > > > tables: I have a table 'Person' which has a to-many relationship to > > > the table 'Folder'. The 'Folder' table will later have a reflexive > > > relationship to itself (so I can have subfolders to every folder). > > > (BTW: is that possible with ObjectBridge right now?) > > > > Yes, it does. We are using it this way now. One of my applications > > has the same structure. It has an "Identity: object which contains many > > "Traits" Traits can contain other Traits. I have two tables Identity > and Trait >[...] > > > In order to model that, the 'Folder' table needs a foreign key which > > > can be NULL for the case that a folder has no parent folder. > > > > In my case I don't allow for a Trait to exist by itself, so a Trait > > has a Trait or an Identity as a parent. I don't formally use a > foreign key. > >Good to hear that. But how do you do the mapping? I currently have no >idea how to accomplish that without a foreign key. Or do you put code >into Trait to retrieve the parent? The Trait doesn't need to retrieve the parent (but it can return the id of its parent if it needs to be retrieved), but I do have code for the parent to retrieve the child if it isn't present. I think the OJB examples do not have foreign keys, either. Several DBMS' I deal with don't handle foreign keys correctly, anyway. Dave >-dirk > >_______________________________________________ >Objectbridge-developers mailing list >Obj...@li... >http://lists.sourceforge.net/lists/listinfo/objectbridge-developers David W. Forslund dw...@la... Computer and Computational Sciences http://www.acl.lanl.gov/~dwf Los Alamos National Laboratory Los Alamos, NM 87545 505-663-5218 FAX: 505-665-4939 |
From: Dirk O. <di...@xa...> - 2001-08-10 05:00:40
|
David Forslund wrote: > > To illustrate things better I'll just give a short description of my > > tables: I have a table 'Person' which has a to-many relationship to > > the table 'Folder'. The 'Folder' table will later have a reflexive > > relationship to itself (so I can have subfolders to every folder). > > (BTW: is that possible with ObjectBridge right now?) > > Yes, it does. We are using it this way now. One of my applications > has the same structure. It has an "Identity: object which contains many > "Traits" Traits can contain other Traits. I have two tables Identity and Trait [...] > > In order to model that, the 'Folder' table needs a foreign key which > > can be NULL for the case that a folder has no parent folder. > > In my case I don't allow for a Trait to exist by itself, so a Trait > has a Trait or an Identity as a parent. I don't formally use a foreign key. Good to hear that. But how do you do the mapping? I currently have no idea how to accomplish that without a foreign key. Or do you put code into Trait to retrieve the parent? -dirk |
From: David F. <dw...@la...> - 2001-08-10 03:39:59
|
At 08:51 PM 8/9/2001, Dirk Olmes wrote: >Hi, > >I just started using ObjectBridge for a small hobby project. I use it >with the FrontBase dbms which had me digging around in the source a bit >to make it work (wasn't hard). Now I found a problem which I could >easily work around but since tihs is a common modeling case I thought of >a general solution. > >To illustrate things better I'll just give a short description of my >tables: I have a table 'Person' which has a to-many relationship to the >table 'Folder'. The 'Folder' table will later have a reflexive >relationship to itself (so I can have subfolders to every folder). (BTW: >is that possible with ObjectBridge right now?) Yes, it does. We are using it this way now. One of my applications has the same structure. It has an "Identity: object which contains many "Traits" Traits can contain other Traits. I have two tables Identity and Trait >In order to model that, the 'Folder' table needs a foreign key which can >be NULL for the case that a folder has no parent folder. In my case I don't allow for a Trait to exist by itself, so a Trait has a Trait or an Identity as a parent. I don't formally use a foreign key. >This empty foreign key already throws an exception when trying to >resolve the relationship from User to Folder. Since JdbcAccess tries to >put values into the Folder instance using reflection it stumbles when >trying to set the null foreign key. > >While I could work around this giving the Folder a special foreign key >(e.g. 0) for the no-parent-folder case I think such cases should be >handled by the framework. Currently, I could think of two possible >solutions to the problem: We have another application that handles the case as you indicate for the "top of the tree" Our objects can be handled by OJB or other Object-Relational mapping tools as well as directly by an OODBMS. I don't like to have a method like "2)" unless it has some other benefit to the object. I hope this helps a little, Dave >1) extend the mapping to let the user specify which value object he >wants to have assigned for individual attributes. So there would be a ><field.valueType/> in addition <field.name/> node in the mapping XML >file. This would allow for e.g. Integer values to be passed. To make >this work with reflection, JdbcAccess should use a set method if that's >available (could be found out using reflection) > >2) define an interface with methods that could let the instance itself >decide what to do in such cases. E.g. we could have a method named >"unableToTakeNullForField(String fieldName)". > >Does anyone have a better idea? > >-dirk > >_______________________________________________ >Objectbridge-developers mailing list >Obj...@li... >http://lists.sourceforge.net/lists/listinfo/objectbridge-developers David W. Forslund dw...@la... Computer and Computational Sciences http://www.acl.lanl.gov/~dwf Los Alamos National Laboratory Los Alamos, NM 87545 505-663-5218 FAX: 505-665-4939 |
From: Dirk O. <di...@xa...> - 2001-08-10 03:00:35
|
Hi, I just started using ObjectBridge for a small hobby project. I use it with the FrontBase dbms which had me digging around in the source a bit to make it work (wasn't hard). Now I found a problem which I could easily work around but since tihs is a common modeling case I thought of a general solution. To illustrate things better I'll just give a short description of my tables: I have a table 'Person' which has a to-many relationship to the table 'Folder'. The 'Folder' table will later have a reflexive relationship to itself (so I can have subfolders to every folder). (BTW: is that possible with ObjectBridge right now?) In order to model that, the 'Folder' table needs a foreign key which can be NULL for the case that a folder has no parent folder. This empty foreign key already throws an exception when trying to resolve the relationship from User to Folder. Since JdbcAccess tries to put values into the Folder instance using reflection it stumbles when trying to set the null foreign key. While I could work around this giving the Folder a special foreign key (e.g. 0) for the no-parent-folder case I think such cases should be handled by the framework. Currently, I could think of two possible solutions to the problem: 1) extend the mapping to let the user specify which value object he wants to have assigned for individual attributes. So there would be a <field.valueType/> in addition <field.name/> node in the mapping XML file. This would allow for e.g. Integer values to be passed. To make this work with reflection, JdbcAccess should use a set method if that's available (could be found out using reflection) 2) define an interface with methods that could let the instance itself decide what to do in such cases. E.g. we could have a method named "unableToTakeNullForField(String fieldName)". Does anyone have a better idea? -dirk |
From: Thomas M. <tho...@ho...> - 2001-08-09 17:01:42
|
Hi Chris, I tried to send you a preview release of the OJB PersistenceBroker Server. unfortunately some mailer daemon refused to forward this mail. thus I decided to prepare a preview release on the OJB homepage, see: http://sourceforge.net/project/showfiles.php?group_id=13647&release_id=47444 You'll find some hints how to get started in my quoted original mail below: cheers, Thomas Thomas Mahler wrote: > > Hi again, > > "Freyer, Chris" wrote: > > > > We will be using a pool of web servers (WebSphere) behind a load balancing > > server. I'm guessing this will cause problems with ObjectBridge. > > Yes, with the current single VM implementation. No, with the new > scalable ObjectServer... > > > > > I've been asked to look at some commercial products. There's a product > > called Visual Business Sight Framework (VBSF) from Object Matter that is > > very similar to your product. I'm checking it out too. > > > > TopLink is also a very feature complete persistence layer. But it's > quite expensive... > > > I'd like to see the pre-release of your stuff. > > See the attached tgz archive. it works just like a "normal" ojb > distribution. > To see the server running just start the shell script server.sh. I have > currently no server.bat for windows but it's really a no-brainer to > write... > > OJB is shipped with the single VM option enabled. to switch to server > mode you have to edit the file > src/test/ojb/ojb.broker.PersistenceBrokerFactoryConfiguration.properties: > set useServer=true to enable the Server mode. > > To use it in a multi-ejb Server environment I would do the following: > > say you have three ejb servers A,B,C and a two servers D, E as OJB > Objectservers. (Of course it's possible to run the OJB server on the > same physical machine as an ejb server). > 1. start server.sh on machines D and E (the server runs on port 2001 by > default) > 2. edit the file PersistenceBrokerFactoryConfiguration.properties on > machines A, B and C as follows: > BrokerServers=D\:2001,E\:2001 > useServer=true > > running in this configuration A, B, and C share the same pool of > BrokerServers D and E. There is also a roundrobin loadbalancing > implemented that will distribute the load between D and E. > > Currently there is NO proper lock-management implemented, that could > handle access conflicts between D and E. > This will be the next big effort. > > > I've used DBGen to create > > some of the beans on this project. It automates much of the routine work, > > and is a good start when doing persistent beans. > > Did you just use it to reverse engineer Java classes from the database > schema? Or did you any changes to the DBGen code for some OJB specific > things? If so I'd be quite happy if you could share this code! > > cheers, > > Thomas > > > > > > > Thanks-- > > Chris Freyer > > Java Contractor > > E-commerce Dept. > > HomeSide Lending, Inc. > > (904) 281-3219 > > > > -----Original Message----- > > From: Thomas Mahler [SMTP:tho...@ho...] > > Sent: Monday, August 06, 2001 3:15 AM > > To: Freyer, Chris > > Subject: Re: objectbridge > > > > Hi Chris, > > > > thanks for your interest in OJB. > > I was on vacation and thus could not answer earlier. I hope you > > don't > > mind. > > > > "Freyer, Chris" wrote: > > > > > > hi thomas, > > > > > > I'm probably going to use ObjectBridge in a very large intranet > > application. > > > Your performance analysis was really great because we use VAJ and > > WebSphere > > > here, and we've had really bad performance with EJB's under > > WebSphere. > > > > > > If you don't mind, could you let me know of any issues that aren't > > on the > > > web? In particular, issues with scalability or performance in a > > large > > > environment (50 - 100 concurrent users for 16 hrs per day). > > > > As I mentioned in the performance study I was doubting whether OJB > > could > > be even faster for updates than plain JDBC. > > Actually there was a bug in the broker which prevented execution of > > updates. This bug is now fixed and there have been several drastic > > performance improvements for using OJB with DB2 and Oracle. > > Thus the numbers from that study should be still valid. But I have > > no > > upto-date numbers. > > > > Scalability: > > until now OJB can not be used savely accross several JVMs. That is: > > if > > you use it within a servlet or EJB container running on one physical > > machine everything should work fine. > > Even the workload you mention should not result in problems. > > Scalability > > is then limited to the scalibility of the underlying hardware. > > > > But running it within an EJB container that is running of several > > physical machines is not save (regarding object locking, caching, db > > writes and reads). > > > > I'm currently working on a highly scalable OJB Object-Server that > > will > > allow to use an arbitrary number of jvms on an arbitrary number of > > physical machines. > > I will release a first version of this server within the next two > > weeks. > > If you are interested I could provide you with a pre-release. > > > > > > > > Also-my database schema already exists. I'm planning to modify > > dbGen > > > (http://dbgen.sourceforge.net) so that it outputs the required > > > object-mapping XML document. I can't do it by hand because I've > > got over > > > 100 tables with 3 - 30 fields each. > > > > Yes that's a very good idea. I was also thinking of reusing parts of > > DBGEN for generation of the O/R mappings. It would be great if you > > could > > contribute your solution to our codebase! > > > > regards, > > > > Thomas > > > > > > > > Thanks- > > > Chris Freyer > > > Java contractor > > > HomeSide Lending, Inc. > > > Cf...@ho... <mailto:> > > > (904) 281-3219 > > > > > > This message may contain confidential information. We provide > > customer > > > information to others only under certain circumstances, and based > > on > > > representations that each applicable customer has authorized the > > disclosure. > > > If any person makes a false or misleading representation to obtain > > customer > > > information, that person may have committed a federal crime, and > > we may > > > report any such incident to the proper authorities. If you > > received this in > > > error, please notify the sender by fax or e-mail and delete this > > message. If > > > you properly received this message, you may use and distribute it > > only in > > > accordance with our instructions and applicable law. HomeSide and > > its > > > affiliates do not represent, warrant or guarantee that the > > integrity of this > > > communication has been maintained nor that the communication is > > free of > > > errors, viruses or interference. > > > > This message may contain confidential information. We provide customer > > information to others only under certain circumstances, and based on > > representations that each applicable customer has authorized the disclosure. > > If any person makes a false or misleading representation to obtain customer > > information, that person may have committed a federal crime, and we may > > report any such incident to the proper authorities. If you received this in > > error, please notify the sender by fax or e-mail and delete this message. If > > you properly received this message, you may use and distribute it only in > > accordance with our instructions and applicable law. HomeSide and its > > affiliates do not represent, warrant or guarantee that the integrity of this > > communication has been maintained nor that the communication is free of > > errors, viruses or interference. > > ------------------------------------------------------------------------ > Name: ojb-0.5.150-src.tgz > ojb-0.5.150-src.tgz Type: unspecified type (application/octet-stream) > Encoding: base64 |
From: Mahler T. <tho...@it...> - 2001-08-09 09:40:26
|
Hi Ivan, I found a way to use the ScriptTool to connect to a given Database with username and password. You have to edit the sql1.txt file as follows: ; First load the JDBC driver and open the demo-database. d COM.ibm.db2.jdbc.app.DB2Driver; o jdbc:db2:dbalias username password; (this is a sample for DB 2). Attached you find a modified sql1.txt that works fine with DB2. Maybe = you can try it with postgresql. HTH Thomas > -----Urspr=FCngliche Nachricht----- > Von: Mahler Thomas [mailto:tho...@it...] > Gesendet: Mittwoch, 8. August 2001 11:36 > An: 'Ivan Toshkov' > Cc: obj...@li... > Betreff: AW: AW: [Objectbridge-developers] Q: How to setup=20 > the database? >=20 >=20 > Hi Ivan, >=20 > > -----Urspr=FCngliche Nachricht----- > > Von: Ivan Toshkov [mailto:to...@cr...] > > Gesendet: Mittwoch, 8. August 2001 10:50 > > An: Mahler Thomas > > Cc: obj...@li... > > Betreff: Re: AW: [Objectbridge-developers] Q: How to setup=20 > > the database? > >=20 > >=20 > > Hi Mahler, > >=20 > > Thanks for your help. > >=20 > > I have some more questions, though. > >=20 > > 1) How is the file `slq1.txt' generated? Is there a way to=20 > > create such > > file for other objects, as well? >=20 > this file was written manually. it is used by the instantDB=20 > ScriptTool to > perform database operations like creating tables and=20 > insertinmg test data. >=20 > What "other objects" do you have in mind? >=20 > >=20 > > 2) The setup[.bat] runs class=20 > > `org.enhydra.instantdb.ScriptTool', which > > is obviously part of InstantDB. At least I couldn't find a=20 > way to set > > the user and password properties and therefore couldn't use it with > > postgresql. >=20 > The documentation for the instantDB ScriptTool is here: > http://www.lutris.com/products/projects/instantDB/software/doc umentation/idb 4_0/sample-applications.html#scriptool As far as I see, there is no option to specify a user or password :-( So you will have to write the DDL manually... Will not be too difficult = for just the two tables...=20 >=20 > I work on a web-based reservation system, using java=20 > servlets, jsps and > xml/xslt. We have developed our own persistence layer, but it=20 > isn't too > mature, yet. It supports only forward engineering and the=20 > developert has > little or no control over the table structuring. I'm in a process of > research for alternatives and I like the ObjectBridge very much. >=20 > I will be very glad to contribute to the project. You are welcome to contribute. OJB currently has no tools for forward- = or reverse engineering or graphically composing the O/R mappings. So your know-how in this area will help a lot! cheers, Thomas >=20 > Cheers, > Ivan >=20 _______________________________________________ Objectbridge-developers mailing list Obj...@li... http://lists.sourceforge.net/lists/listinfo/objectbridge-developers |
From: Mahler T. <tho...@it...> - 2001-08-09 06:16:28
|
Hallo Christian! > -----Urspr=FCngliche Nachricht----- > Von: Christian Sell [mailto:chr...@ne...] > Gesendet: Mittwoch, 8. August 2001 18:54 > An: Mahler Thomas > Betreff: Re: [Objectbridge-developers] Q: How to setup the databas e? >=20 >=20 > Hi Thomas and all, >=20 > doe these mapping variations support polymorphism (sorry if this is > mentioned in the docs)? I.e., if I select A's via OQL, do I=20 > get B's and C's > as well - correctly instantiated, of course. >=20 Yes, Polymorphism is fully supported. That is if you select for A's = with some criteria you will get all A's, B's and C's that match this = criteria. Polymorphism works also with interfaces. That if A implements interface = IA (and B and C extending A) and you have a query on IA with some criteria = you will get all A's, B's and C's. All objects will be properly instantiated. There is a sample for this feature in test.ojb.broker with classes InterfaceArticle, Article, BookArticle and CdArticle demonstrating the respective mapping = techniques. > Option 3 seems like the most obvious mapping variation for=20 > inheritance - any > plans to support it soon? >=20 I don't agree on that. All three variants may be appropiate solutions = to model a class hierarchy. I had a lot of discussions with experienced software developers and DBA's and none of them ever used Option three. = All people I spoke to agreed that this variant is not as performant as the others as it needs a join about at least two tables for retrieving even = the simplest object of a derived class. OJB allows you to work with such a database schema if neccessary: You = have to define a 1-1 mapping between tables A and B (and A and C) and you = will need some kind of wrapper object that maintains the 1-1 relationship. That's not ideal but it works. Until now there have been no requests to implement the "Option 3", thus = I have currently no plans to implement it. (nevertheless, volunteers to do this job are always welcome :-) ) regards, Thomas > ----- Original Message ----- > From: "Mahler Thomas" <tho...@it...> > To: "'Ivan Toshkov'" <to...@cr...>; "Mahler Thomas" > <tho...@it...> > Cc: "Objectbridge (E-Mail)"=20 > <obj...@li...> > Sent: Wednesday, August 08, 2001 4:53 PM > Subject: AW: AW: AW: AW: [Objectbridge-developers] Q: How to setup = the > databas e? >=20 >=20 >=20 >=20 > > -----Urspr=FCngliche Nachricht----- > > Von: Ivan Toshkov [mailto:to...@cr...] > > Gesendet: Mittwoch, 8. August 2001 16:33 > > An: Mahler Thomas > > Betreff: Re: AW: AW: AW: [Objectbridge-developers] Q: How=20 > to setup the > > databas e? > > > > > > Hi again, > > > > I couldn't find an example of using OJB with an hierarchy=20 > of classes. > > The only exception is test.ojb.broker.Article and > > test.ojb.broker.BookArticle, but the latter does not add any > > new fields, > > so it's not exactly what I'm looking for. > > >=20 > It does! BookArticle has two additional attributes: > /** books author*/ > private String author; > /** ISBN No of Book*/ > private String isbn; >=20 > (VisualAge does not keep all attributes at the top of a class=20 > definition. I > guess that's why you did not find those attributes.) >=20 > There is also the class CdArticle that does not extend Article but > implements the interface Article and introduces also two more=20 > attributes > than Article. >=20 > > To be more specific, let's say we have the following classes: > > > > abstract class A > > { > > int num; > > } > > > > class B extends A > > { > > String name; > > } > > > > class C extends A > > { > > int count; > > } > > > > The theory says, there are generally 3 representations: > > > > 1. Store the whole hierarchy in one table: > > > > table A: > > +-----+-----+------+-------+------+ > > | oid | num | name | count | type | > > +-----+-----+------+-------+------+ > > >=20 > supported by OJB. In the ClassDescriptor of each class you=20 > just have to > declare that it maps to table A. >=20 > > 2. Store each concrete class in separate table: > > > > table B: > > +-----+-----+------+ > > | oid | num | name | > > +-----+-----+------+ > > > > table C: > > +-----+-----+-------+ > > | oid | num | count | > > +-----+-----+-------+ > > >=20 > supported by OJB. > In the ClassDescriptor for class B you have to declare that=20 > it maps to table > B (same for Class C and table C). >=20 > > 3. Store each class in a separate table: > > > > table A: > > +-----+-----+ > > | oid | num | > > +-----+-----+ > > > > table B: > > +-----+------+ > > | oid | name | > > +-----+------+ > > > > table C: > > +-----+-------+ > > | oid | count | > > +-----+-------+ > > >=20 > not directly supported. Could be relaized via a foreign key relation. >=20 > HTH, >=20 > Thomas >=20 > > Which of these are currently supported by OJB and how do the XML > > description looks like? > > > > Best regards, > > Ivan > > >=20 > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > http://lists.sourceforge.net/lists/listinfo/objectbridge-developers >=20 |
From: Mahler T. <tho...@it...> - 2001-08-08 14:55:15
|
> -----Urspr=FCngliche Nachricht----- > Von: Ivan Toshkov [mailto:to...@cr...] > Gesendet: Mittwoch, 8. August 2001 16:33 > An: Mahler Thomas > Betreff: Re: AW: AW: AW: [Objectbridge-developers] Q: How to setup = the > databas e? >=20 >=20 > Hi again, >=20 > I couldn't find an example of using OJB with an hierarchy of classes. > The only exception is test.ojb.broker.Article and > test.ojb.broker.BookArticle, but the latter does not add any=20 > new fields, > so it's not exactly what I'm looking for. >=20 It does! BookArticle has two additional attributes: /** books author*/ private String author; /** ISBN No of Book*/ private String isbn; (VisualAge does not keep all attributes at the top of a class = definition. I guess that's why you did not find those attributes.) There is also the class CdArticle that does not extend Article but implements the interface Article and introduces also two more = attributes than Article. > To be more specific, let's say we have the following classes: >=20 > abstract class A > { > int num; > } >=20 > class B extends A > { > String name; > } >=20 > class C extends A > { > int count; > } >=20 > The theory says, there are generally 3 representations: >=20 > 1. Store the whole hierarchy in one table: >=20 > table A: > +-----+-----+------+-------+------+ > | oid | num | name | count | type | > +-----+-----+------+-------+------+ >=20 supported by OJB. In the ClassDescriptor of each class you just have to declare that it maps to table A. > 2. Store each concrete class in separate table: >=20 > table B: > +-----+-----+------+ > | oid | num | name | > +-----+-----+------+ >=20 > table C: > +-----+-----+-------+ > | oid | num | count | > +-----+-----+-------+ >=20 supported by OJB. In the ClassDescriptor for class B you have to declare that it maps to = table B (same for Class C and table C). > 3. Store each class in a separate table: >=20 > table A: > +-----+-----+ > | oid | num | > +-----+-----+ >=20 > table B: > +-----+------+ > | oid | name | > +-----+------+ >=20 > table C: > +-----+-------+ > | oid | count | > +-----+-------+ >=20 not directly supported. Could be relaized via a foreign key relation. HTH, Thomas=20 > Which of these are currently supported by OJB and how do the XML > description looks like? >=20 > Best regards, > Ivan >=20 |
From: Ivan T. <to...@cr...> - 2001-08-08 11:30:58
|
On 08 Aug 2001 13:05:36 +0300, Ivan Toshkov wrote: > Hmm, > > Obviously, there will be bigger problems with postgresql. It appears > that OID is reserved column name in postgresql. Is there an easy fix for > that in OJB? > It worked! I changed OID and POSITION columns to _OID and POS respectively. |
From: Ivan T. <to...@cr...> - 2001-08-08 10:26:02
|
Hmm, Obviously, there will be bigger problems with postgresql. It appears that OID is reserved column name in postgresql. Is there an easy fix for that in OJB? On 08 Aug 2001 11:35:43 +0200, Mahler Thomas wrote: > > What "other objects" do you have in mind? Well, the business objects for other applications than the tutorials. > > You are welcome to contribute. OJB currently has no tools for forward- or > reverse engineering or graphically composing the O/R mappings. So your > know-how in this area will help a lot! > I'll have to dig a little more in the XML mapping descriptors. Do you think they will be enough to create the tables? It definetly works for the Product class, but this is the simplest case. |
From: Mahler T. <tho...@it...> - 2001-08-08 09:37:22
|
Hi Ivan, > -----Urspr=FCngliche Nachricht----- > Von: Ivan Toshkov [mailto:to...@cr...] > Gesendet: Mittwoch, 8. August 2001 10:50 > An: Mahler Thomas > Cc: obj...@li... > Betreff: Re: AW: [Objectbridge-developers] Q: How to setup=20 > the database? >=20 >=20 > Hi Mahler, >=20 > Thanks for your help. >=20 > I have some more questions, though. >=20 > 1) How is the file `slq1.txt' generated? Is there a way to=20 > create such > file for other objects, as well? this file was written manually. it is used by the instantDB ScriptTool = to perform database operations like creating tables and insertinmg test = data. What "other objects" do you have in mind? >=20 > 2) The setup[.bat] runs class=20 > `org.enhydra.instantdb.ScriptTool', which > is obviously part of InstantDB. At least I couldn't find a way to set > the user and password properties and therefore couldn't use it with > postgresql. The documentation for the instantDB ScriptTool is here: http://www.lutris.com/products/projects/instantDB/software/documentation= /idb 4_0/sample-applications.html#scriptool As far as I see, there is no option to specify a user or password :-( So you will have to write the DDL manually... Will not be too difficult = for just the two tables...=20 >=20 > I work on a web-based reservation system, using java=20 > servlets, jsps and > xml/xslt. We have developed our own persistence layer, but it=20 > isn't too > mature, yet. It supports only forward engineering and the=20 > developert has > little or no control over the table structuring. I'm in a process of > research for alternatives and I like the ObjectBridge very much. >=20 > I will be very glad to contribute to the project. You are welcome to contribute. OJB currently has no tools for forward- = or reverse engineering or graphically composing the O/R mappings. So your know-how in this area will help a lot! cheers, Thomas >=20 > Cheers, > Ivan >=20 |
From: Ivan T. <to...@cr...> - 2001-08-08 09:01:52
|
Hi Mahler, Thanks for your help. I have some more questions, though. 1) How is the file `slq1.txt' generated? Is there a way to create such file for other objects, as well? 2) The setup[.bat] runs class `org.enhydra.instantdb.ScriptTool', which is obviously part of InstantDB. At least I couldn't find a way to set the user and password properties and therefore couldn't use it with postgresql. I work on a web-based reservation system, using java servlets, jsps and xml/xslt. We have developed our own persistence layer, but it isn't too mature, yet. It supports only forward engineering and the developert has little or no control over the table structuring. I'm in a process of research for alternatives and I like the ObjectBridge very much. I will be very glad to contribute to the project. Cheers, Ivan |
From: Mahler T. <tho...@it...> - 2001-08-08 06:29:01
|
Hi Ivan, For The first tutorial you only need two tables in your database: the product table for the tutorial and the the sequence-manager table = that keeps track of primary key values. here the respective DDL fragments from the file = src/test/setup/sql1.txt: ;;; Product Table for Tutorial 1 e DROP TABLE PRODUCT; e CREATE TABLE PRODUCT ( ID INT NOT NULL UNIQUE PRIMARY KEY, NAME CHAR(100), PRICE DOUBLE, STOCK INT ); ; create the OJB SequenceManager table e DROP TABLE OJB_SEQ; e CREATE TABLE OJB_SEQ ( CLASSNAME CHAR(512) NOT NULL UNIQUE PRIMARY KEY, FIELDNAME CHAR(256) NOT NULL UNIQUE PRIMARY KEY, CURRENT INT ); You can do 2 things to get this tables created in your db 1. Do it manually with statements appropriate for Postgresql. 2. do it automatically with the ojb build process: - change the first lines of sql1.txt to point to your postgresql = database: d org.enhydra.instantdb.jdbc.idbDriver; // replace with postgresql = driver classname o jdbc:idb:demo.prp; // replace with url of your database - run build.sh tests (under u*x) or build tests (under win32)=20 HTH=09 Thomas -----Urspr=FCngliche Nachricht----- Von: Ivan Toshkov [mailto:to...@cr...] Gesendet: Dienstag, 7. August 2001 16:46 An: obj...@li... Betreff: [Objectbridge-developers] Q: How to setup the database? Hi list, I'm trying to run the tutorial1 example w/ postgresql. How should I initially setup the database? Thank, Ivan Toshkov _______________________________________________ Objectbridge-developers mailing list Obj...@li... http://lists.sourceforge.net/lists/listinfo/objectbridge-developers |
From: Ivan T. <to...@cr...> - 2001-08-07 14:46:04
|
Hi list, I'm trying to run the tutorial1 example w/ postgresql. How should I initially setup the database? Thank, Ivan Toshkov |
From: Mahler T. <tho...@it...> - 2001-08-07 06:03:40
|
Hi Dave, =20 I'm checking in to CVS only immediately before finishing a release. = Thus your SqLGenerator fix is not yet there. But it is not lost! It will be = there in the next release! I did not use the binary switch while checking in the JAR files, thus = they are bogus. I will fix it in the next release! Thanks for for your hint. =20 Regarding the Oracle patch: It's also not in CVS. It is not even on my = build machine, as the guys who did it have not mailed it to me yet ;-( I will urge them to send it to me so that I can mail it to you asap. =20 regards, =20 =20 Thomas -----Urspr=FCngliche Nachricht----- Von: David Forslund [mailto:dw...@la...] Gesendet: Dienstag, 7. August 2001 05:08 An: Thomas Mahler Cc: obj...@li... Betreff: Re: [Objectbridge-developers] Other databases I did a fresh checkout of the current CVS repository, but I'm not sure = it has been updated. It doesn't have the corrections we sent you in June to correct the SqlGenerator. =20 It also has a number of bad jar files. I had to replace 4-5 of the jar files in the lib directory because they were defective. I was hoping it would have the changes = you mentioned for Oracle.=20 Thanks, Dave At 09:06 AM 8/6/2001, David W Forslund wrote: Please send us the changes to work with Oracle. We are trying to get = it running and we can store data but don't get any data back. Dave Thomas Mahler writes: > Hi David, >=20 > David Forslund wrote: > >=20 > > Does anyone have an example of configuring OJB with other = databases? >=20 > I'm using OJB with DB2 without any modifications. > Some colleagues of mine are using it with Oracle. They had to make = some > minor changes which will be included in some of the next releases to > allow out of the box usage with Oracle too. > I'm planning to support MYSQL too. >=20 > I see no general problems regarding MSAccess. In fact I was using = Access > as demo database before I found instantDB. > I guess your problem with loading the driver class must be a class = path > problem. If you are using the build.xml file for running your > application you might change the property runtime_classpath to = include > your driver class. >=20 > If you want to use the default JDBC-ODBC driver there might be some > problems: afaik this driver is only JDBC 1.0 compliant. But the OJB > Factory classe for jdbc-statements is written for jdbc 2.0. > But only a few lines of class StatementsForClass are affected by = this > change. Maybe I can get it working for both JDBC versions in a = future > release. >=20 > Thomas >=20 >=20 >=20 > > I tried to configure the junit test to use MSAccess and it fails = to > > even find the JDBC Driver although I can use that driver in other = apps > > just fine. > >=20 > > Thanks, > >=20 > > David W. Forslund dw...@la... > > Computer and Computational > > Sciences http://www.acl.lanl.gov/~dwf <http://www.acl.lanl.gov/~dwf>=20 > > Los Alamos National Laboratory Los Alamos, NM > > 87545 > > 505-665-1907 FAX: 505-665-4939 >=20 >=20 > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > http://lists.sourceforge.net/lists/listinfo/objectbridge-developers <http://lists.sourceforge.net/lists/listinfo/objectbridge-developers>=20 _______________________________________________ Objectbridge-developers mailing list Obj...@li... http://lists.sourceforge.net/lists/listinfo/objectbridge-developers <http://lists.sourceforge.net/lists/listinfo/objectbridge-developers>=20 David W. Forslund dw...@la... =20 Computer and Computational Sciences http://www.acl.lanl.gov/~dwf <http://www.acl.lanl.gov/~dwf>=20 Los Alamos National Laboratory Los Alamos, NM 87545 = 505-663-5218 FAX: 505-665-4939 |
From: David F. <dw...@la...> - 2001-08-07 03:08:25
|
I did a fresh checkout of the current CVS repository, but I'm not sure it has been updated. It doesn't have the corrections we sent you in June to correct the SqlGenerator. It also has a number of bad jar files. I had to replace 4-5 of the jar files in the lib directory because they were defective. I was hoping it would have the changes you mentioned for Oracle. Thanks, Dave At 09:06 AM 8/6/2001, David W Forslund wrote: >Please send us the changes to work with Oracle. We are trying to get it >running and we can store data but don't get any data back. > >Dave >Thomas Mahler writes: > > Hi David, > > > > David Forslund wrote: > > > > > > Does anyone have an example of configuring OJB with other databases? > > > > I'm using OJB with DB2 without any modifications. > > Some colleagues of mine are using it with Oracle. They had to make some > > minor changes which will be included in some of the next releases to > > allow out of the box usage with Oracle too. > > I'm planning to support MYSQL too. > > > > I see no general problems regarding MSAccess. In fact I was using Access > > as demo database before I found instantDB. > > I guess your problem with loading the driver class must be a class path > > problem. If you are using the build.xml file for running your > > application you might change the property runtime_classpath to include > > your driver class. > > > > If you want to use the default JDBC-ODBC driver there might be some > > problems: afaik this driver is only JDBC 1.0 compliant. But the OJB > > Factory classe for jdbc-statements is written for jdbc 2.0. > > But only a few lines of class StatementsForClass are affected by this > > change. Maybe I can get it working for both JDBC versions in a future > > release. > > > > Thomas > > > > > > > > > I tried to configure the junit test to use MSAccess and it fails to > > > even find the JDBC Driver although I can use that driver in other apps > > > just fine. > > > > > > Thanks, > > > > > > David W. Forslund dw...@la... > > > Computer and Computational > > > Sciences http://www.acl.lanl.gov/~dwf > > > Los Alamos National Laboratory Los Alamos, NM > > > 87545 > > > 505-665-1907 FAX: 505-665-4939 > > > > > > _______________________________________________ > > Objectbridge-developers mailing list > > Obj...@li... > > http://lists.sourceforge.net/lists/listinfo/objectbridge-developers > >_______________________________________________ >Objectbridge-developers mailing list >Obj...@li... >http://lists.sourceforge.net/lists/listinfo/objectbridge-developers David W. Forslund dw...@la... Computer and Computational Sciences http://www.acl.lanl.gov/~dwf Los Alamos National Laboratory Los Alamos, NM 87545 505-663-5218 FAX: 505-665-4939 |
From: David W F. <dw...@la...> - 2001-08-06 15:06:20
|
Please send us the changes to work with Oracle. We are trying to get it running and we can store data but don't get any data back. Dave Thomas Mahler writes: > Hi David, > > David Forslund wrote: > > > > Does anyone have an example of configuring OJB with other databases? > > I'm using OJB with DB2 without any modifications. > Some colleagues of mine are using it with Oracle. They had to make some > minor changes which will be included in some of the next releases to > allow out of the box usage with Oracle too. > I'm planning to support MYSQL too. > > I see no general problems regarding MSAccess. In fact I was using Access > as demo database before I found instantDB. > I guess your problem with loading the driver class must be a class path > problem. If you are using the build.xml file for running your > application you might change the property runtime_classpath to include > your driver class. > > If you want to use the default JDBC-ODBC driver there might be some > problems: afaik this driver is only JDBC 1.0 compliant. But the OJB > Factory classe for jdbc-statements is written for jdbc 2.0. > But only a few lines of class StatementsForClass are affected by this > change. Maybe I can get it working for both JDBC versions in a future > release. > > Thomas > > > > > I tried to configure the junit test to use MSAccess and it fails to > > even find the JDBC Driver although I can use that driver in other apps > > just fine. > > > > Thanks, > > > > David W. Forslund dw...@la... > > Computer and Computational > > Sciences http://www.acl.lanl.gov/~dwf > > Los Alamos National Laboratory Los Alamos, NM > > 87545 > > 505-665-1907 FAX: 505-665-4939 > > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > http://lists.sourceforge.net/lists/listinfo/objectbridge-developers |
From: Thomas M. <tho...@ho...> - 2001-08-06 14:00:06
|
Hi Kief, Kief Morris wrote: > > Howdy, I've been banging on some code, and so far ojb is pretty cool, > but I've run into a few things. > > 1) Dates: I had some issues storing fields of type java.util.Date, which > may or may not be specific to the mySQL JDBC driver. I notice the > example application doesn't use and date/time fields, has this been > tested much with other drivers? > > The issue is that ojb uses PreparedStatement.setObject(int parameterIndex, Object x) > to store fields, and the mySQL driver at least doesn't automatically figure > out what type this is: the result is it stores 0 as the date/time value. > Using setObject(index, myDate, java.sql.Types.TIMESTAMP) works, > as does wrapping the Date object with java.sql.Timestamp, which is > the workaround I've used in my code. > We have similar problems with other drivers too! The Oracle driver for example returns all Number columns as BigDecimal even if the Objects attribute is only a int. We will have to improve this behaviour! For the time being you might work with a ConversionStrategy that makes an explicit TypeConversion before reading and writing from JDBC ResultSets. See the tutorial on this topic: http://objectbridge.sourceforge.net/conversions.html > 2) ObjectCache doesn't appear to retrieve referenced objects. When I > store and then retrieve an object which references a collection, the > retrieved object doesn't have the collection items. If I insert: > > ojb.broker.accesslayer.ObjectCache.getInstance().clear(); > > - between the store and the find, the retrieved object *does* have > the collection. I don't totally understand this - presumably the cache > should return the same object, including its references, but a comparison > of the two objects without the above call shows one has the collection, > the other's collection is empty. > You are right, store does not cache the object. That's why a different object reference is returned by getObjectByQuery(...) There was no special reason for this, but I guess I will change it, because the semantics is really a bit funny due to this asymmetry... I have no idea why your Collection is not filled. This is a thing that MUST work! You might send me your source code (only the relevant stuff) and your repository.xml file to check what's wrong. regards, Thomas > Thanks, > Kief > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > http://lists.sourceforge.net/lists/listinfo/objectbridge-developers |
From: Thomas M. <tho...@ho...> - 2001-08-06 10:07:36
|
Kief Morris wrote: > > Kief Morris typed the following on 12:49 PM 7/29/2001 +0300 > >The error I'm getting at the moment may or may not be related to > >the table structures. Here's the exception: > > > > [junit] java.lang.AbstractMethodError > ... > >So apparently the prepareStatement() method of the Connection object > >returned by > >my JDBC driver is considered to be abstract? > > OK, I should have dug into this more before asking. A newer version > of the JDBC driver worked fine, so presumably the method wasn't > implemented in the older version. I have now successfully written a row > to a mysql table using ojb! congratulations! > > Any clarification on the table structures would be appreciated, though. See http://sourceforge.net/forum/forum.php?thread_id=97263&forum_id=43066 for a litte docu on the tables! Thomas > > Thanks, > Kief > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > http://lists.sourceforge.net/lists/listinfo/objectbridge-developers |
From: Thomas M. <tho...@ho...> - 2001-08-06 10:03:42
|
Hi Kief, Kief Morris wrote: > > Hello, I've just started working with OJB, and I must say I quite > like it. I had partially developed a similar package myself last year, > but decided that since DB code isn't a focus of my work (and it's > a considerable time sink) I needed to find something else to use. > OJB fits the bill very neatly, thanks to those of you who've been > developing it. > > I'm having a few problems however. I have a project using mySQL, > and I haven't got the database bridge in place yet. > > One problem is I'm not sure how to structure the tables which ojb > uses. I've used the information in repository.xml to create the tables, > but I'm not sure (a) how big the CHAR columns should be, or The CHAR columns hold serialized OID objects. An OID is a wrapper object to databases primary key. As primary keys can be compound of an arbitrary number of columns, the size of these columns depends on your DB schema. I guess 512 may be a sound value. > (b) whether I need to put anything in for the CollectionDescriptors - > foreign keys? CollectionDescriptors are medadata for 1-n relationships in your databases schema. thus you need foreign keys in your dependend table, containing primary key values from the master table. The CollectionDescriptor contains a list of indexes of the primary keys of the master table (<descriptor_ids>index1,index2,...]</descriptor_ids>) > I'll put the table definitions I'm using at the end of this > message - I decided to make most of the CHAR fields 255 characters > to start with, and to ignore the collections since I can't see anything > relating to table columns in the xml. > > The error I'm getting at the moment may or may not be related to > the table structures. Here's the exception: > > [junit] Running com.kief.babbletest.ForumTest > [junit] OJB Descriptor Repository: file:/C:/src/new/babble/test/conf/repository.xml > [junit] connection.prepareStatement(connection.nativeSQL(SELECT CLASSNAME, FIELDNAME, CURRENT FROM OJB_SEQ WHERE (CLASSNAME = ?) AND (FIELDNAME = ?)), 1004, 1007) > [junit] java.lang.AbstractMethodError > [junit] at ojb.broker.accesslayer.StatementsForClass.prepareStatement(StatementsForClass.java:123) > [junit] at ojb.broker.accesslayer.StatementsForClass.getSelectByPKkStmt(StatementsForClass.java:246) > [junit] at ojb.broker.accesslayer.StatementManager.getSelectByPKStatement(StatementManager.java:196) > [junit] at ojb.broker.accesslayer.JdbcAccess.materializeObject(JdbcAccess.java:253) > [junit] at ojb.broker.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:776) > > The third line is output from a println I put in immediately before the error, which happens > on the line: > > result = connection.prepareStatement(nsql, TYPE, CONCUR); this method signature is not present in JDBC 1.0 drivers thus you get the abstract method error! Use a JDBC 2.0 driver instead or change the source code to use the jdbc 1.0 signature: connection.prepareStatement(nsql); > > So apparently the prepareStatement() method of the Connection object returned by > my JDBC driver is considered to be abstract? I'm not sure why this would be, > prepared statements do work on this driver in other code of mine. Any clues? > I'm using mm.mysql.jdbc-1.2c, my relevant repository.xml looks like: > > <JdbcConnectionDescriptor id="default"> > <dbms.name>BabbleTest</dbms.name> > <driver.name>org.gjt.mm.mysql.Driver</driver.name> > <url.protocol>jdbc</url.protocol> > <url.subprotocol>mysql</url.subprotocol> > <url.dbalias>//localhost/wild5</url.dbalias> > </JdbcConnectionDescriptor> > > Has anybody else reported using ojb successfully with mySQL? Some people tried but I did not get any responses if they had problems or not. I'm planning to have a regular support for mySql as well as for DB2 and Oracle. > > Thanks for any help. > > Here are the table structures I'm using: > > -- For Class ojb.odmg.NamedRootsEntry > CREATE TABLE IF NOT EXISTS OJB_NRM ( > NAME VARCHAR(255) NOT NULL, > OID VARCHAR(64), > PRIMARY KEY (NAME) > ); the length for name is ok (you won't have names longer than 255 bytes, will you?) But the size for the OID shoould be bigger as it will contain fully serialized OID Object, say 512! > > -- For Class ojb.odmg.collections.DListImpl > CREATE TABLE IF NOT EXISTS OJB_DLIST ( > ID INT NOT NULL, > SIZE INT, > -- CollectionDescriptor > PRIMARY KEY (ID) > ); No need to maintain anything regarding CollectionDescriptors in this table! All items in a DList collection are maintained in the OJB_DLIST_ENTRIES table. > > -- For Class ojb.odmg.collections.DListEntry > CREATE TABLE IF NOT EXISTS OJB_DLIST_ENTRIES ( > ID INT NOT NULL, > DLIST_ID INT, > POSITION INT, > OID VARCHAR(64), > PRIMARY KEY (ID) > ); > Make OID bigger (same reason as above)! > -- For Class ojb.broker.SequenceEntry > CREATE TABLE IF NOT EXISTS OJB_SEQ ( > CLASSNAME VARCHAR(255) NOT NULL, > FIELDNAME VARCHAR(64), > CURRENT INT, > PRIMARY KEY (CLASSNAME) > ); > > -- For Class ojb.odmg.collections.DBagImpl > CREATE TABLE IF NOT EXISTS OJB_DLIST ( > ID INT NOT NULL, > SIZE INT, > -- CollectionDescriptor > PRIMARY KEY(ID) > ); Don't worry about the Collection Descriptors here :-) > > -- For Class ojb.odmg.collections.DSetImpl > CREATE TABLE IF NOT EXISTS OJB_DSET ( > ID INT NOT NULL, > SIZE INT, > -- CollectionDescriptor > PRIMARY KEY(ID) > ); > > -- For Class ojb.odmg.collections.DSetEntry > CREATE TABLE IF NOT EXISTS OJB_DSET_ENTRIES ( > ID INT NOT NULL, > DLIST_ID INT, > POSITION INT, > OID VARCHAR(255), > PRIMARY KEY(ID) > ); OID should be bigger > > -- For Class ojb.odmg.collections.DMapImpl > CREATE TABLE IF NOT EXISTS OJB_DMAP ( > ID INT NOT NULL, > SIZE INT, > -- CollectionDescriptor > PRIMARY KEY(ID) > ); > > -- For Class ojb.odmg.collections.DMapEntry > CREATE TABLE IF NOT EXISTS OJB_DMAP_ENTRIES ( > ID INT NOT NULL, > DMAP_ID INT, > KEY_OID VARCHAR(64), > VALUE_OID VARCHAR(64), > PRIMARY KEY(ID) > ); > KEY_OID, VALUE_OID should be bigger (see above). regards, Thomas > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > http://lists.sourceforge.net/lists/listinfo/objectbridge-developers |
From: Thomas M. <tho...@ho...> - 2001-08-06 09:04:20
|
Hi David, David Forslund wrote: > > Does anyone have an example of configuring OJB with other databases? I'm using OJB with DB2 without any modifications. Some colleagues of mine are using it with Oracle. They had to make some minor changes which will be included in some of the next releases to allow out of the box usage with Oracle too. I'm planning to support MYSQL too. I see no general problems regarding MSAccess. In fact I was using Access as demo database before I found instantDB. I guess your problem with loading the driver class must be a class path problem. If you are using the build.xml file for running your application you might change the property runtime_classpath to include your driver class. If you want to use the default JDBC-ODBC driver there might be some problems: afaik this driver is only JDBC 1.0 compliant. But the OJB Factory classe for jdbc-statements is written for jdbc 2.0. But only a few lines of class StatementsForClass are affected by this change. Maybe I can get it working for both JDBC versions in a future release. Thomas > I tried to configure the junit test to use MSAccess and it fails to > even find the JDBC Driver although I can use that driver in other apps > just fine. > > Thanks, > > David W. Forslund dw...@la... > Computer and Computational > Sciences http://www.acl.lanl.gov/~dwf > Los Alamos National Laboratory Los Alamos, NM > 87545 > 505-665-1907 FAX: 505-665-4939 |
From: Kief M. <ki...@bi...> - 2001-07-30 10:21:30
|
Kief Morris typed the following on 11:27 AM 7/30/2001 +0300 >2) ObjectCache doesn't appear to retrieve referenced objects. When I > store and then retrieve an object which references a collection, the > retrieved object doesn't have the collection items. If I insert: > > ojb.broker.accesslayer.ObjectCache.getInstance().clear(); > > - between the store and the find, the retrieved object *does* have > the collection. I don't totally understand this - presumably the cache > should return the same object, including its references, but a comparison > of the two objects without the above call shows one has the collection, > the other's collection is empty. Aha! The cache wasn't returning the same object, because objects were only being added to the cache (as far as I can tell) when they were retrieved from the DB, not when they were saved. So consider the following steps: 1) create new object 2) store it 3) retrieve a copy of the object 4) compare the object references The comparison failed, because the objects were different instances. So I've attached a small patch which causes the PersistentManager to add items to the cache when they are stored. Maybe this is redundant for updates, it could be moved inside the conditional so it only happens on inserts. I didn't dig into the reason why the loaded copy of the original object didn't load its referenced collection - as I mentioned in the previous message, clearing the cache and then loading the copy did in fact load the collection. I'm guessing there is a check somewhere which caught the fact that the collection was already loaded in memory, so didn't bother to reload it. At any rate it seems to work fine now. Regards, Kief |
From: Kief M. <ki...@ki...> - 2001-07-30 08:26:43
|
Howdy, I've been banging on some code, and so far ojb is pretty cool, but I've run into a few things. 1) Dates: I had some issues storing fields of type java.util.Date, which may or may not be specific to the mySQL JDBC driver. I notice the example application doesn't use and date/time fields, has this been tested much with other drivers? The issue is that ojb uses PreparedStatement.setObject(int parameterIndex, Object x) to store fields, and the mySQL driver at least doesn't automatically figure out what type this is: the result is it stores 0 as the date/time value. Using setObject(index, myDate, java.sql.Types.TIMESTAMP) works, as does wrapping the Date object with java.sql.Timestamp, which is the workaround I've used in my code. 2) ObjectCache doesn't appear to retrieve referenced objects. When I store and then retrieve an object which references a collection, the retrieved object doesn't have the collection items. If I insert: ojb.broker.accesslayer.ObjectCache.getInstance().clear(); - between the store and the find, the retrieved object *does* have the collection. I don't totally understand this - presumably the cache should return the same object, including its references, but a comparison of the two objects without the above call shows one has the collection, the other's collection is empty. Thanks, Kief |
From: Kief M. <ki...@bi...> - 2001-07-29 14:35:19
|
Kief Morris typed the following on 12:49 PM 7/29/2001 +0300 >The error I'm getting at the moment may or may not be related to >the table structures. Here's the exception: > > [junit] java.lang.AbstractMethodError ... >So apparently the prepareStatement() method of the Connection object >returned by >my JDBC driver is considered to be abstract? OK, I should have dug into this more before asking. A newer version of the JDBC driver worked fine, so presumably the method wasn't implemented in the older version. I have now successfully written a row to a mysql table using ojb! Any clarification on the table structures would be appreciated, though. Thanks, Kief |
From: Kief M. <ki...@bi...> - 2001-07-29 09:49:14
|
Hello, I've just started working with OJB, and I must say I quite like it. I had partially developed a similar package myself last year, but decided that since DB code isn't a focus of my work (and it's a considerable time sink) I needed to find something else to use. OJB fits the bill very neatly, thanks to those of you who've been developing it. I'm having a few problems however. I have a project using mySQL, and I haven't got the database bridge in place yet. One problem is I'm not sure how to structure the tables which ojb uses. I've used the information in repository.xml to create the tables, but I'm not sure (a) how big the CHAR columns should be, or (b) whether I need to put anything in for the CollectionDescriptors - foreign keys? I'll put the table definitions I'm using at the end of this message - I decided to make most of the CHAR fields 255 characters to start with, and to ignore the collections since I can't see anything relating to table columns in the xml. The error I'm getting at the moment may or may not be related to the table structures. Here's the exception: [junit] Running com.kief.babbletest.ForumTest [junit] OJB Descriptor Repository: file:/C:/src/new/babble/test/conf/repository.xml [junit] connection.prepareStatement(connection.nativeSQL(SELECT CLASSNAME, FIELDNAME, CURRENT FROM OJB_SEQ WHERE (CLASSNAME = ?) AND (FIELDNAME = ?)), 1004, 1007) [junit] java.lang.AbstractMethodError [junit] at ojb.broker.accesslayer.StatementsForClass.prepareStatement(StatementsForClass.java:123) [junit] at ojb.broker.accesslayer.StatementsForClass.getSelectByPKkStmt(StatementsForClass.java:246) [junit] at ojb.broker.accesslayer.StatementManager.getSelectByPKStatement(StatementManager.java:196) [junit] at ojb.broker.accesslayer.JdbcAccess.materializeObject(JdbcAccess.java:253) [junit] at ojb.broker.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:776) The third line is output from a println I put in immediately before the error, which happens on the line: result = connection.prepareStatement(nsql, TYPE, CONCUR); So apparently the prepareStatement() method of the Connection object returned by my JDBC driver is considered to be abstract? I'm not sure why this would be, prepared statements do work on this driver in other code of mine. Any clues? I'm using mm.mysql.jdbc-1.2c, my relevant repository.xml looks like: <JdbcConnectionDescriptor id="default"> <dbms.name>BabbleTest</dbms.name> <driver.name>org.gjt.mm.mysql.Driver</driver.name> <url.protocol>jdbc</url.protocol> <url.subprotocol>mysql</url.subprotocol> <url.dbalias>//localhost/wild5</url.dbalias> </JdbcConnectionDescriptor> Has anybody else reported using ojb successfully with mySQL? Thanks for any help. Here are the table structures I'm using: -- For Class ojb.odmg.NamedRootsEntry CREATE TABLE IF NOT EXISTS OJB_NRM ( NAME VARCHAR(255) NOT NULL, OID VARCHAR(64), PRIMARY KEY (NAME) ); -- For Class ojb.odmg.collections.DListImpl CREATE TABLE IF NOT EXISTS OJB_DLIST ( ID INT NOT NULL, SIZE INT, -- CollectionDescriptor PRIMARY KEY (ID) ); -- For Class ojb.odmg.collections.DListEntry CREATE TABLE IF NOT EXISTS OJB_DLIST_ENTRIES ( ID INT NOT NULL, DLIST_ID INT, POSITION INT, OID VARCHAR(64), PRIMARY KEY (ID) ); -- For Class ojb.broker.SequenceEntry CREATE TABLE IF NOT EXISTS OJB_SEQ ( CLASSNAME VARCHAR(255) NOT NULL, FIELDNAME VARCHAR(64), CURRENT INT, PRIMARY KEY (CLASSNAME) ); -- For Class ojb.odmg.collections.DBagImpl CREATE TABLE IF NOT EXISTS OJB_DLIST ( ID INT NOT NULL, SIZE INT, -- CollectionDescriptor PRIMARY KEY(ID) ); -- For Class ojb.odmg.collections.DSetImpl CREATE TABLE IF NOT EXISTS OJB_DSET ( ID INT NOT NULL, SIZE INT, -- CollectionDescriptor PRIMARY KEY(ID) ); -- For Class ojb.odmg.collections.DSetEntry CREATE TABLE IF NOT EXISTS OJB_DSET_ENTRIES ( ID INT NOT NULL, DLIST_ID INT, POSITION INT, OID VARCHAR(255), PRIMARY KEY(ID) ); -- For Class ojb.odmg.collections.DMapImpl CREATE TABLE IF NOT EXISTS OJB_DMAP ( ID INT NOT NULL, SIZE INT, -- CollectionDescriptor PRIMARY KEY(ID) ); -- For Class ojb.odmg.collections.DMapEntry CREATE TABLE IF NOT EXISTS OJB_DMAP_ENTRIES ( ID INT NOT NULL, DMAP_ID INT, KEY_OID VARCHAR(64), VALUE_OID VARCHAR(64), PRIMARY KEY(ID) ); |