Differences between revisions 19 and 20
Revision 19 as of 2007-04-18 19:41:17
Size: 24616
Editor: monahanky
Comment:
Revision 20 as of 2009-09-20 22:56:19
Size: 24616
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

2007-04-18

Hi,

I need to download the source code for OJB 1.0.3. I'm just wondering where can I get it from? Can it be downloaded from subversion?

Thank you


2007-03-22

Hi,

I've got a problem with MULTIPLE-LEVEL INHERITANCE. I use the strategy with reference-descriptor name="super" on OJB 1.0.4.

When I make a query to obtain the instances of B (which extend A) :

  • I haven't got any problem

But if I define a super-class of A called AA : the same query doesn't work.

More simply, my question is :

  • Is it possible to make query using superclass
    • in an inheritance hierarchy of depth more than 2 ?

PS : No problem for me if you use OJB-specialist terms

  • because I have used OJB since 2 years.

Note : query using AA doesn't work too. Nevertheless in all cases,

  • I can query explictly the sub-classes of the bottom of the hierarchy tree.


2005-11-04

Hi,

I would like to know whether it is possible to obtain field lengths from the DB through OJB in order to use them in a HTML form to limit the number of characters a user can input.

Regards, Ed


2004-10-06

Hi,

I have found the error (is it a error o a bug?): the method deleteByQuery() of PersistenceBroker don't delete the record in the table that link User and Group. If i use the delete() of PersistenceBroker the record in the table that link User and Group is removed.

I have received no advice, perhaps I don't understand the meaning of this wiki or my english is too bad ;-)


2004-09-30

Hi,

I'm using OJB for mapping a m:n relation between two entity: User and Group,

+--------+ n                     n +---------+
+  User  +-------------------------+  Group  +
+--------+                         +---------+

On the db I have three table, SU2_GRUPPI (group table), SU2_UTENTI (user table) and SU2_UTEGRU that link user and group.

The problem is that if i delete a group, the record that link the group with the user isn't deleted from SU2_UTEGRU even if I specified auto-delete="link", I debugged sql.SqlGeneratorDefaultImpl but there is only a delete on the table of group.

...
4702  DEBUG [http-8080-Processor23] sql.SqlGeneratorDefaultImpl - SQL:SELECT A0.gru_id,A0.gru_descri FROM SU2_GRUPPI A0 WHERE A0.gru_id = ?
8110  DEBUG [http-8080-Processor23] sql.SqlGeneratorDefaultImpl - SQL:DELETE FROM SU2_GRUPPI WHERE gru_id = ?
8126  DEBUG [http-8080-Processor23] sql.SqlGeneratorDefaultImpl - SQL:SELECT A0.gru_id,A0.gru_descri FROM SU2_GRUPPI A0
10190 DEBUG [http-8080-Processor23] sql.SqlGeneratorDefaultImpl - SQL:SELECT A0.gru_id,A0.gru_descri FROM SU2_GRUPPI A0

This is the source code:

public static void deleteByTemplate(Object template) 
{
  PersistenceBroker broker = null;
  try
  {                     
    broker = PersistenceBrokerFactory.defaultPersistenceBroker();
    QueryByCriteria query = new QueryByCriteria(template);
    broker.deleteByQuery(query);
  }
  finally
  {
    if (broker != null) broker.close();
  }
}

This is the repository_user

<class-descriptor class="it.cedaf.portale.persistence.G" table="SU2_GRUPPI">
        <field-descriptor id="0" name="id" column="gru_id" jdbc-type="VARCHAR" primarykey="true"/>
        <field-descriptor id="1" name="descrizione" column="gru_descri" jdbc-type="VARCHAR"/>

        <collection-descriptor
                name="utenti"
                element-class-ref="it.cedaf.portale.persistence.Utente"
                indirection-table="SU2_UTEGRU"
                auto-update="link"
                auto-delete="link"
        >
                <fk-pointing-to-this-class column="utg_id_gru"/>
                <fk-pointing-to-element-class column="utg_id_ute"/>
        </collection-descriptor>
                
</class-descriptor>

<class-descriptor class="it.cedaf.portale.persistence.Utente" table="SU2_UTENTI">
        <field-descriptor id="0" name="id" column="ute_id" jdbc-type="VARCHAR" primarykey="true"/>
        <field-descriptor id="1" name="tipo" column="ute_tipo" jdbc-type="CHAR"/>
        <field-descriptor id="2" name="password" column="ute_passwd" jdbc-type="VARCHAR"/>
        <field-descriptor id="3" name="dataScadenza" column="ute_dtscad" jdbc-type="TIMESTAMP"/>
        <field-descriptor id="4" name="descrizione" column="ute_descri" jdbc-type="VARCHAR"/>
        <field-descriptor id="5" name="email" column="ute_email" jdbc-type="VARCHAR"/>
</class-descriptor>


2004-09-24

Hello,

I have started a Blog on how to keep a Domain Model free of persistence logic (http://ricbrown.blogspot.com/2004/09/transparent-persistence-paradox.html).

I was wondering how Jakarta OJB handles keeping persistence logic out of the Domain Model when the domain logic needs to search a large collection of elements (e.g., to check that a property is unique)?

Regards,

  • Richard

2004-06-23: Good Afternoon,

Does Ojb support in any way PL/SQL?

[MartinKalen]: Please explaing what you want to do. If you obtain a Connection object from an OJB PersistenceBroker using the following call you execute Statement and PreparedStatement with the features (and limitations) of your current JDBC-driver:

PersistenceBroker:
public ConnectionManagerIF serviceConnectionManager();

ConnectionManagerIF:
public Connection getConnection() throws LookupException;


2004-05-15: All is not well in the land of Tomcat+Struts+OJB+Fedora Core release 1 (Yarrow) (This is a report of OJB Bug 260)

Please send a useful tips to Jason A. Lunn <galactus@mac.com> in addition to leaving answers here.

Relevant System info:

Fedora Core release 1 (Yarrow) Linux localhost.localdomain 2.4.22-1.2188.nptl #1 Wed Apr 21 20:35:41 EDT 2004 i686 athlon i386 GNU/Linux

S/W environment:

jakarta-tomcat-4.1.30
jakarta-struts-1.1
j2sdk1.4.2
apache-ant-1.6.0
commons-collections-3.0
commons-dbcp-1.1
commons-dbutils-1.0
commons-pool-1.1
db-ojb-1.0.rc6

Problem: Every piece of sample code or home brew code that I try to use under struts that make use of ojb generates this exception at runtime:

java.lang.NoClassDefFoundError: org/apache/commons/collections/CursorableLinkedList at org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl.createPool(PersistenceBrokerFactoryDefaultImpl.java:206) at
org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl.<init>(PersistenceBrokerFactoryDefaultImpl.java:72) at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at
java.lang.reflect.Constructor.newInstance(Constructor.java:274) at
java.lang.Class.newInstance0(Class.java:308) at java.lang.Class.newInstance(Class.java:261) at
org.apache.ojb.broker.util.ClassHelper.newInstance(ClassHelper.java:39) at
org.apache.ojb.broker.core.PersistenceBrokerFactoryFactory.init(PersistenceBrokerFactoryFactory.java:60) at
org.apache.ojb.broker.core.PersistenceBrokerFactoryFactory.<clinit>(PersistenceBrokerFactoryFactory.java:36) at
org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroker(PersistenceBrokerFactory.java:65) 

....

I have included commons-collections.jar in both the WEB-INF/lib directory and tomcat/common/lib; I have tried rebuilding commons-pool.jar after editing the source to reference org.apache.commons.collections.list.CursorableLinkedList instead of the deprecated org.apache.commons.collections.CursorableLinkedList to no avail.

---

Hi all! [mehmet.sariyar@rizit.at @ 04.01.07:18:12:43 wrote]

Although tried any modifications described in the "how-to's", I wasn't already able to build up an inheritance using concept of setting superclasses primary-key as primary-and-foreign-key of the subclass. Everything is well functioning, the primitive fields of the superclass are loaded together with the loaded subclass. BUT reference-descriptors and collection-descriptiors described in the super-class will be ignored, not give damn about them!

Here a look-like :

<class-descriptor class="A" table="A">
        <field-descriptor id="0" name="pk_aid" column="PK_AID" jdbc-type="INTEGER" primarykey="true"
                          autoincrement="true"/>
        <field-descriptor id="1" name="fk_broadid" column="FK_BroadID" jdbc-type="INTEGER"/>
        <field-descriptor id="2" name="fk_userid" column="FK_UserID" jdbc-type="INTEGER"/>
        <field-descriptor id="3" name="name" column="Name" jdbc-type="VARCHAR"/>
        <field-descriptor id="4" name="unittyp" column="UnitTyp" jdbc-type="CHAR"/>
        <!-- begin:references -->
                <reference-descriptor   name="broad" class-ref="Broad"
                                        auto-retrieve="true" auto-update="false" auto-delete="false">
                        <foreignkey field-ref="fk_broadid"/>
                </reference-descriptor>
                <reference-descriptor   name="user" class-ref="User"
                                        auto-retrieve="true" auto-update="false" auto-delete="false">
                        <foreignkey field-ref="fk_userid"/>
                </reference-descriptor>
        <!-- end:references -->
        <!-- begin:collections -->
                <collection-descriptor  name="allCasts" element-class-ref="Cast"
                                        auto-retrieve="true" auto-update="true" auto-delete="true"
                                        orderby="pk_castid" sort="ASC">
                        <inverse-foreignkey field-ref="fk_aid"/>
                </collection-descriptor>
                <collection-descriptor  name="allHistories" element-class-ref="History"
                                        auto-retrieve="true" auto-update="true" auto-delete="true"
                                        orderby="pk_historyid" sort="ASC">
                        <inverse-foreignkey field-ref="fk_aid"/>
                </collection-descriptor>
        <!-- end:collections -->
</class-descriptor>

<class-descriptor class="B" table="B">
        <field-descriptor 
                id="0"
                name="fk_aid" <!-- in RDBMS it is a primary-key and a foreign-key-reference in one -->
                column="FK_AID"
                jdbc-type="INTEGER"
                primarykey="true"/>
        <field-descriptor 
                id="1"
                name="fk_clientid"
                column="FK_ClientID"
                jdbc-type="INTEGER"
        />
        <!-- begin:references -->
                <reference-descriptor   name="super" class-ref="A"
                                        auto-retrieve="true" auto-update="true" auto-delete="true">
                        <foreignkey field-ref="fk_aid"/>
                </reference-descriptor>
                <reference-descriptor   name="client" class-ref="Client"
                                        auto-retrieve="true" auto-update="true" auto-delete="true">
                        <foreignkey field-ref="fk_clientid"/>
                </reference-descriptor>
        <!-- end:references -->
</class-descriptor>

Does anyone have any experience with CONCEPT#3 of Inheritance O/R-Mapping ?

Please mail to address above.

:Thnx:


Hello,

Simple question - not sure if it's answered in OJB docs or this Wiki (if so, I can't find it or don't understand it).

I'd like to know if OJB supports both:

1) Taking a set of Java classes and generating DDL (and optionally mapping)

2) Taking a schema (DDL) and generating corresponding Java classes (and optionally mapping)

Please send answers to robertprince99@yahoo.com

Thanks! :)


Hi

I want to know if I can do the following example :

class C{
        private int val;
        public C(){
}
        public int getVal() { return val; }
        public void setVal(int val){ 
        this.val = val; 
        }
}

class B{
        private List l1;

        public B(){
                this.l1 = new ListFactory.createList(C.class);
}
        public List getL1(){
                return this.l1 ;
        }
}
class A{
        private List l2;
        private List l3;

        public A()      {
                this.l2 = new ListFactory.createList(C.class);
                this.l3 = new ListFactory.createList(C.class);
        }
        public List getL2(){
                return this.l2 ;
        }
        public List getL3(){
                return this.l3 ;
        }
}

I want to map the C object 3 times like this : · One BC table for the C object in the B.l1 list, · One AC1 table for the C object in the C.l1 list, · One AC2 table for the C object in the C.l2 list.

Is it possible, if not how to do it ?


I do the following enhance,but nothing happend! platform:

  jdori 1.0.1 (9/22/2003)
  ojb 1.0.rc4

java -classpath jdo\jdo.jar;do\jdori.jar;jdo\jdori-enhancer.jar;energy\data;.;  com.sun.jdori.enhancer.Main -v -f -d enhanced Project energy.jdo  energy\data\Project.class
Enhancer: options:
    verbose = true
    quiet = false
    forceWrite = true
    noWrite = false
    sourcePath = null
    destinationDirectory = enhanced
    propertiesFileName = null
    doTiming = false
    classNames = {
        Project
    }
    jdoFileNames = {
        energy.jdo
    }
    classFileNames = {
        energy\data\Project.class
    }
    zipFileNames = {
    }
    dumpClass = false
    noAugment = false
    noAnnotate = false
JDO ENHANCER: using file: file:/C:/Data/project/energy/data/classes/energy/data/Project.class
Class Locator: using class files: {
    energy\data\Project.class
}
JDO ENHANCER: using file: file:/C:/Data/project/energy/data/classes/energy.jdo

---------------------------------------------------------------------------------------------------------

JDO ENHANCER: Enhancer: enhancing classfile ...
JDO ENHANCER: scanning class energy.data.Project
JDO ENHANCER: not found resource: META-INF/package.jdo
JDO ENHANCER: not found resource: WEB-INF/package.jdo
JDO ENHANCER: not found resource: package.jdo
JDO ENHANCER: not found resource: energy/package.jdo
JDO ENHANCER: not found resource: energy/data/package.jdo
JDO ENHANCER: not found resource: energy/data/Project.jdo
JDO ENHANCER: has default constructor.
JDO ENHANCER: has not static initializer.
JDO ENHANCER: has not clone method.
JDO ENHANCER: has not writeObject method.
JDO ENHANCER: has not writeReplace method.
JDO ENHANCER: has not readObject method.
JDO ENHANCER: annotating class energy.data.Project
JDO ENHANCER: annotating: energy.data.Project.getId()
JDO ENHANCER: annotating: energy.data.Project.setName(java.lang.String)
JDO ENHANCER: annotating: energy.data.Project.<init>()
JDO ENHANCER: annotating: energy.data.Project.getName()
JDO ENHANCER: annotating: energy.data.Project.setId(java.lang.String)
JDO ENHANCER: no changes to class energy.data.Project

JDO ENHANCER: Enhancer: classfile not changed.
JDO ENHANCER: found resource: Project.class
---------------------------------------------------------------------------

JDO ENHANCER: Enhancer: enhancing classfile ...
JDO ENHANCER: scanning class energy.data.Project
JDO ENHANCER: has default constructor.
JDO ENHANCER: has not static initializer.
JDO ENHANCER: has not clone method.
JDO ENHANCER: has not writeObject method.
JDO ENHANCER: has not writeReplace method.
JDO ENHANCER: has not readObject method.
JDO ENHANCER: annotating class energy.data.Project
JDO ENHANCER: annotating: energy.data.Project.getId()
JDO ENHANCER: annotating: energy.data.Project.setName(java.lang.String)
JDO ENHANCER: annotating: energy.data.Project.<init>()
JDO ENHANCER: annotating: energy.data.Project.getName()
JDO ENHANCER: annotating: energy.data.Project.setId(java.lang.String)
JDO ENHANCER: no changes to class energy.data.Project

JDO ENHANCER: Enhancer: classfile not changed.
done.

OJB JDO implementation seems confict with JDORI 1.0.1

objfiledmanager and objstoremanager in package org.apache.ojb.jdori.sql; need some changes(because sun rmi 1.0.1? maybe it need sun rmi 1.0)


When should we use OJB in a J2EE EJB application? (Presumably we can use OJB as Bean Managed Persistence and an alternative to Container Managed Persistence - but is that a good idea?)


Hello everybody. I have a little problem with this OJB-code:

   String sql = "SELECT MAX(ID)FROM Userdata ";
   QueryBySQL query = QueryFactory.newQuery(Userdata.class, sql);

   Userdata data = (Userdata) broker.getObjectByQuery(query);

The data is always null. What is the mistake in this code ?


Hey!

I'm working with OJB on two Relations! Lets call them A and B! When I try to store an Object in one of these 2 Relations I Sometimes get an

org.apache.ojb.broker.OptimisticLockException: Object has been modified by someone else

Exception. When do I recieve this Exception, I can't find an satisfying API for this Exception!

After making some TestRuns I found out: either I can store Objects in Relation A or I can store an Object in Relation B. Trying to store something in the other Relation always gives me the OptimisticLockException!

Object/Relation A has been 1:n-ojb-mapped to Object/Relation B! I removed this mapping, but it wasn't the solution...

My Store-Methode:

public Object storeObject(Object o) {
                PersistenceBroker broker = null;
                try {
                        broker = getBroker();
                
                        broker.beginTransaction();
                        broker.store(o);
                        broker.commitTransaction();
                } 
                catch (PersistenceBrokerException e)
                {
                 System.out.println("******Error bei storeObject");
                 e.printStackTrace();
                 broker.abortTransaction();
                }
                finally {
                        if (broker != null)
                                broker.close();
                }
                return o;
        }

any solutions? thx

--> oh, seems like I found a solution: in the OJB.properties I have to activate ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl


Some personal experiences

Hi, I tried to set up OJB on RH9.0 with MySQL. It's not really, really straightforward if you know what I mean. Sorry if I come across as an ***hole, but, people, the first build/deploy *must* work without problems or headaches otherwise people will just wander off to another project in 60 seconds. Put it on the to-do-list! Well, it probably already is.

d.tonhofer@m-plify.com

We follow the instructions in the http://db.apache.org/ojb/howto-get-started.html

Download the source distribution using

   $ wget http://db.apache.org/builds/ojb/1.0.rc4/db-ojb-1.0.rc4-src.tgz

and put it into /usr/local/tarballs

Edit build.properties. Comment out profile=hsqldb and uncomment profile=mysql

Edit ./profile/mysql.profile. We have created a test database called toon_xp_tests to which user test can connect from anywhere. Thus, set the databaseUser to test, set the databasePassword. According to the createDatabaseUrl, the new database will be called ojb. We change this to toon_xp_tests. Do *not* change the value of database (which is mysql). It's just an arbitrary name.

Now run ant junit.

This is a headfull junit test! It needs X11! I'm on the text console! Foo! Barfulation!

Kill references to project splash from build.xml.

The compilation is still not gonna work. It wants j2ee.... This is incomprehensible.

Drop this problem for now. We might want to come back to it later.

Try the Tutorial

Get the binary release. Then try to work through the tutorials.

Prepare build.properties and ./profile/mysql.profile as decribed above.

Then prepare the Tutorials:

  $ source bin/build.sh prepare-tutorials > OUT 2>&1

All the errors will now be collected in OUT

Again, we get the splash screen problem. You know what to do (see above). We then get a complaint that j2ee cannot be found. Remove the reference to the check-j2ee-classes in the main depends list. Run the build.sh again.

Then we get:

  BUILD FAILED
  file:/usr/local/tarballs/db-ojb-1.0.rc4/build.xml:143: /usr/local/tarballs/db-ojb-1.0.rc4/src/jca not found.

JCA is (presumably) the Java Cryptography Architecture. What is this about??

Comment out the JCA block in build.xml, i.e.

  <!--
  <copy todir="${build.srcjca}">
      <fileset dir="${src.jca}"/>
  </copy>
  -->

You can just create the directory db-ojb-1.0.rc4/src/jca, this will fix this particular problem.

Ok, fixed that. Build proceeds, but now we have:

  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 '@DATABASE_DEFAULT@' at line 1"

Seems that the variable @DATABASE_DEFAULT@ is not correctly replaced? Siiigghhh!

So we do that manually.

  $ grep -R 'DATABASE_DEFAULT'*

  src/schema/ojbcore-schema.xml:<database name="@DATABASE_DEFAULT@" defaultIdMethod="none">
  src/schema/ojbtest-schema.xml:<database name="@DATABASE_DEFAULT@" defaultIdMethod="none"
  target/src/sql/sqldb.map:ojbtest-data.sql=@DATABASE_DEFAULT@
  target/src/sql/sqldb.map:ojbcore-schema.sql=@DATABASE_DEFAULT@
  target/src/sql/sqldb.map:ojbtest-schema.sql=@DATABASE_DEFAULT@
  target/src/sql/create-db.sql:drop database if exists @DATABASE_DEFAULT@;
  target/src/sql/create-db.sql:create database @DATABASE_DEFAULT@;

This is sucky. There probably should be something in the ant project that does the replacement?

Here we go again:

  $ source bin/build.sh prepare-tutorials 

  BUILD SUCCESSFUL
  Total time: 19 seconds


dmagdali@calpoly.edu

Completely agree with the previous poster. Had the exact same experience except on windows. Also, are these problems new to 1.0rc4? Why are only downloads for the new 1.0.rc* builds available? Why are there no stable versions available?


dave@lledr-solutions.co.uk

Just need a techy question answering. I have an n:m relationship between two tables in a database, using an indirection table to join the two - like this...

User >> Link_User_Country >> Country

...the idea being that Users have access to data in a set of Countries. The data in the Countries table is fixed. Using the indirection-table tag in the repository file is *great* for reading data - there's a "availableCountries" property in my User class which gives me a collection of Country objects.

What I've hit a problem with is updates and deletions. I'd like to be able to just add and remove Countries from the availableCountries collection and for these actions to add and remove records from the indirection table (Link_User_Country). It's actually adding/removing records in both the indirection table AND the Country table (with all the associated database errors!). So - what would be the best way of implementing this given that; a) I want an easy to use collection of Country objects accessible from my User object b) Inserts and Deletions should only occur in the link table

Help! Thanks


oliver.baum@wwk.de

We're using OJB with the MSSQL DB. Now we have problems with the reconnect to the DB when the DB was down. Can somebody tell me what we can do?

Entry in the respository.xml:

<jdbc-connection-descriptor jcd-alias="default" default-connection="true" platform="MsSQLServer" jdbc-level="2.0" driver="com.microsoft.jdbc.sqlserver.SQLServerDriver" protocol="jdbc" subprotocol="microsoft:sqlserver" dbalias="//serv114:1433;SelectMethod=cursor;databasename=sqltest" username="***" password="***" batch-mode="false" useAutoCommit="2" ignoreAutoCommitExceptions="false" >

<sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"> </sequence-manager>

<connection-pool maxActive="10" validationQuery="select count(*) from OJB_HL_SEQ" />

Thanks Olly


barry.whiting@clocktowermews.org.uk

Hi,

I wondered if some one could help me with using the AES_ENCRYPT in mysql with OJB. I am trying to store some information encrypted but I cant seem to find the answer.

Thanks Barry


Hi,

I am in need of help. I am trying to use the reference-descriptor to set up a 1:1 relationship between two classes. In my class Container I have a id, name, and project_id. In the Project class, I have a id, name. I want to be able to do the following search

Criteria c = new Criteria();
c.addLike("name", likeSearchString);
Criteria c4 = new Criteria();
c4.addLike("project.name", likeSearchString);
c.addOrCriteria(c4);
Collection containerSearch = Container.getAllContainers(c);

I have a getProject() method in my container class and I even put the reference-descriptor tag into my repository-myproject.xml file. When I run my code, it errors out saying "Can't find member project in com.mycompany.myporject.core.om.Conatiner". I have yet to come across anything that deals with this error, so I don't know if I wam forgetting something or I need to put some code elsewhere.

Thanks for the Help,

Ryan


YourQuestionHere (last edited 2009-09-20 22:56:19 by localhost)