You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Brian McCallister <mc...@forthillcompany.com> on 2003/12/10 15:19:13 UTC

Re: Newbie questions

On Dec 10, 2003, at 4:08 AM, Mahbub ul Huq Bin Kabir wrote:

> Hi,
>
> I’m a very new comer to this technology and don’t have clear idea 
> about persistence layer. So I decided to ask some question to this 
> group and hopefully get a reply.

Happy to (try) to help!

> Now I’m using the JDBC API for the development. I’m handling a large 
> database with simple JDBC and have to generate reports continuously, 
> which also contains lot of data as its contents. But I want to use the 
> Persistence layer and I choose to use the OJB. I’m also using struts 
> for my application development.
>
> First of all, I have to know the basics.
>
> §	Do I have to create classes for all the Tables of my database?

No, you do not *have* to, however most O/R models at least start with a 
1:1 object:table correlation.

> §	I have to use JOIN in my query to get the results from the database, 
> do I have to create class for the joining in OJB?

OJB typically does joins via 1:N or M:N relationships between objects 
using the Collections API. If you are doing different types of 
filtering (say, "select e.* from employees e inner join departments d 
on (e.dept_id = d.id and d.name like ?)" it gets to be trickier but can 
still be done. Typically that type of filtering is more easily handled 
in the Java code when using an O/R mapping tool like OJB.

Actually, looking at the above example the better way to do it from an 
O/R perspective would be to retrieve the department ("select dept from 
" + Department.class.getName() + "where name = $1") and then map 
employees in that department as a collection on the Department. So 
while you are looking for employees, you are really looking for a 
department's employees.

> §	OJB doesn’t provide the aggregate function, how this could be solve 
> in OJB?

I will let someone else answer this one ;-)

> §	What about the performance when handling large database and what 
> about the memory requirements?

Carefully crafted SQL can almost always be faster to execute than any 
O/R tool as there is simply an extra execution layer between the data 
and the logic. OJB performs *very* well for an O/R tool and you would 
typically need a very well crafted set of queries, and a strong 
hand-crafted caching system, to get better overall performance. O/R 
tools, and OJB as one, typically trade a little bit of performance 
potential (potential being key) for a lot of productivity.

> §	Between the Persistence Broker, ODMG, JDO which one I should use and 
> why?

It depends on your needs. There are situations where one is better than 
the other, but it very much depends on your exact needs.

-Brian


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: How to set up a ojb-jdo project

Posted by Gus Heck <gu...@olin.edu>.
This looks like a runtime error not a compile time error.

This exception means, as you guessed, that either you forgot to enhance 
the class (with the sun reference enhancer), or the enhancer tried and 
failed (you should get messages if it fails). Alternately, you have 
inadvertently tried to get an extent of some other class that isn't 
supposed to be persistant.

Do you get any error messages during enhancement?

Also, as always, check that your app is really getting re-deployed 
properly, and you arn't seeing errors from an old version that is still 
running. I use the Tomcat Manager App's Ant tasks for this, so I don't 
have to worry about making sure I delete the warfiles, and the expanded 
warfile, and I don't need to worry about whatever is in the work directory.

Also, you can eliminate repository_junit.xml and repository_internal.xml 
(and thier references in repository.xml)

I'm not sure how anything is working unless you have flattened the 
directory structure in your listing of files... the standard web ap 
directory structure is:

+--WEB-INF--+
|           +--classes/     <<< all class files in package dirs,
|           |                  repository.xml & .dtd ,
|           |                  OJB.properties plus
|           |                  package.jdo/classname.jdo files
|           |                  in appropriate dirs
|           +--lib/         <<< All library jars here
|           |                  (db-ojb-1.0.rc4.jar, jdo.jar etc)
|           +--web.xml
+--index.jsp
+--staic-page.html
+--whatever-content-dirs/

Sourcefiles for your classes are not needed anywhere, and can be 
ommited. Taglib descriptor (.tld) files can go anywhere, as long as your 
pages specify their location correctly. I tend to put mine in /WEB-INF/lib.

Hope some of this helps, please create a new thread instead of replying 
to an existing one next time you have a new question. The way you did it 
you will only get seen by people who think "Newbie questions... please 
help" is an interesting subject, or who do not view thier mail as 
threads.You probably want the widest possible audience ;)

-Gus

Sebastian Münch wrote:

> Hi,
>
> we are in the middle of developing a small application using the jdo 
> api on
> ojb. The
> tutorials are running fine, now we wanna setup our own app. By 
> compiling our
> application,
> we get the following error:
>
>
> [JDO] DEBUG: OjbStoreConnector.begin: connectionReadyForRelease=false
> javax.jdo.JDOUserException: Class given to getExtent does not implement
> javax.jdo.spi.PersistenceCapable
> 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)
> at test.TestApp.run(TestApp.java:57)
> at test.TestApp.main(TestApp.java:25)
> Exception in thread "main" javax.jdo.JDOUserException: Cannot close
> PersistenceManager while transaction is still active.
> at com.sun.jdori.common.PersistenceManagerImpl.close(Unknown Source)
>
> at
> com.sun.jdori.common.PersistenceManagerImpl.popCurrentWrapper(Unknown
> Source)
> at com.sun.jdori.common.PersistenceManagerWrapper.close(Unknown
> Source)
> at test.TestApp.run(TestApp.java:76)
> at test.TestApp.main(TestApp.java:25)
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
> Our persistent class is HJSTest. We applied the HSJTest.jdo to our
> Userclass. The
> following files are located In our project directory:
>
>
> HSJTest.jdo
> OJB.properties
> TestApp.class
> TestApp.sh
> Test_ClassDescriptor.xml
> Test_ConnectionDescriptor.xml
> Test_Repository.xml
> cache.ccf
> commons-logging.properties
> jdo.dtd
> log4j.properties
> repository.dtd
> repository.xml
> repository_database.xml
> repository_ejb.xml
> repository_internal.xml
> repository_jdo.xml
> repository_junit.xml
> repository_user.xml
> simplelog.properties
> spy.properties
> test/
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
> Our source code including compiled files are located in the test/ 
> directory.
>
>
>
> We believe, that there is a problem with the Enhancer, adding the
> PersistenceCapable -
> Interface to our Class. Can anybody help us on that sibject?
>
> Thx,
> Jing, Holger, Sebastian
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


How to set up a ojb-jdo project

Posted by Sebastian Münch <se...@gmx.net>.
Hi, 
 
we are in the middle of developing a small application using the jdo api on
ojb. The 
tutorials are running fine, now we wanna setup our own app. By compiling our
application, 
we get the following error: 
 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
[JDO] DEBUG: OjbStoreConnector.begin: connectionReadyForRelease=false 
javax.jdo.JDOUserException: Class given to getExtent does not implement 
javax.jdo.spi.PersistenceCapable 
        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) 
        at test.TestApp.run(TestApp.java:57) 
        at test.TestApp.main(TestApp.java:25) 
Exception in thread "main" javax.jdo.JDOUserException: Cannot close 
PersistenceManager while transaction is still active. 
        at com.sun.jdori.common.PersistenceManagerImpl.close(Unknown Source)

        at
com.sun.jdori.common.PersistenceManagerImpl.popCurrentWrapper(Unknown 
Source) 
        at com.sun.jdori.common.PersistenceManagerWrapper.close(Unknown
Source) 
        at test.TestApp.run(TestApp.java:76) 
        at test.TestApp.main(TestApp.java:25) 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
 
Our persistent class is HJSTest. We applied the HSJTest.jdo to our
Userclass. The 
following files are located In our project directory: 
 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
HSJTest.jdo 
OJB.properties 
TestApp.class 
TestApp.sh 
Test_ClassDescriptor.xml 
Test_ConnectionDescriptor.xml 
Test_Repository.xml 
cache.ccf 
commons-logging.properties 
jdo.dtd 
log4j.properties 
repository.dtd 
repository.xml 
repository_database.xml 
repository_ejb.xml 
repository_internal.xml 
repository_jdo.xml 
repository_junit.xml 
repository_user.xml 
simplelog.properties 
spy.properties 
test/ 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
 
Our source code including compiled files are located in the test/ directory.

 
 
We believe, that there is a problem with the Enhancer, adding the
PersistenceCapable - 
Interface to our Class. Can anybody help us on that sibject? 
 
Thx, 
Jing, Holger, Sebastian 

-- 
+++ GMX - die erste Adresse für Mail, Message, More +++
Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org