Speedo FAQ


Back to the Speedo documentation


How to build the speedo.jar file?

You have to run the default task ('archives') of the build.xml provided in the Speedo distribution.

How to create data structure ?

By default at runtime, the first time Speedo is asked to manage a persistent class, it tries to initialize the data structure (SQL tables) associated to the class.

Nevertheless when using Speedo in an application server, some databases do not support the creation of the data structure inside a XA transaction. In this case, the user must create the data structure before the launching the server. To do this, Speedo provides a class which initializes the the data structure of persistent classes, outside the scope of a transaction. This class is named 'org.objectweb.speedo.tools.DataStructureCreation'. The Speedo examples show usages of this class through the ant target 'createDataStruct' provided with their build.xml. In fact, the main method of the class expects, as arguments, the names of classes to initialize (white space as separator).

java org.objectweb.speedo.tools.DataStructureCreation com.foo.MyPersistentClass1 com.foo.MyPersistentClass2


How to compile Speedo?

The speedo project uses the version 1.6 of Jarkata Ant. In addition you have to put the junit.jar (in the 'externals' directory) with the ant libraries ($ANT_HOME/lib).
Target Description
compile compile the project in the ./output/build directory
dist create the speedo distribution in the ./output/dist directory
zip create the zip file corresponding to the project and the distribution. The zip file are created into the ./output/zip directory
test run all speedo tests


How to desactivate data prefetching?

Set the properties 'org.objectweb.speedo.query.prefetch.query' or 'org.objectweb.speedo.query.prefetch.extent' to 'off' in the speedo-jdo.properties (or speedo-ejb.properties according to the speedo personnality you use) configuration file.

Speedo and the database integrity constraints ?

Some database schemas contains definition of integrity constraints like a foreign key definition. As other persistence containers, Speedo cannot support that the integrity constraint have to be check at each database action. You have to defer the chekcing at commit time. Indeed the persistence containers cannot known the right order to flush modification on the database. A following way shows a declaration of a foreign key constraint which is checked at commit time.

#declaration of a first table TA
create table TA (
A_ID NUMBER(30) not null,
constraint PK_MESSAGE primary key (A_ID));

# declaration of a first table TB
create table TB (
B_ID NUMBER(30) not null,
AID NUMBER(30),
constraint PK_MESSAGE primary key (B_ID));

# declaration of a foreign key contraint with the checking deferred at commit time
alter table TB
add constraint MY_CONSTRAINT_NAME foreign key (AID)
references TA (A_ID)
initially deferred deferrable;

The important thing to see is the last point: initially deferred deferrable, because it is this option which specifies that the constraint is checked at commit time.

How to specify a field as index of a Map ?

In some cases you want to have a Map of persistent classes indexed by the a field of the referenced classes such as the following example:

class A {
/**
* value = a B
* key = B.f1
*/
Map mapOfB;
...
}
class B {
String f1
...
}

Speedo supports this mapping only in case of the B class has no sub classes. To knwon how to specify this mapping see the section about Map field in the user manual.

How to map two fields on the same column ?

In some cases you want to map two persistent fields on the same column. Speedo permits this mapping except for two primitive fields. The way to declare two fields on the same column is very simple. You only have to specify the same column name for both fields

The following example shows the mapping of a primitive fields and a reference field on the same SQL column.

class A {
String myid;
String idb;
B myb;
...
}
class B {
String myid
...
}

#the .jdo file
<class name="A"/>
<field name="myid" primary-key="true">
<extension vendor-name="speedo" key="sql-name" value="PKA"/>
</field>
<field name="idb">
<!-- the field idb is mapped over the column FKB -->
<extension vendor-name="speedo" key="sql-name" value="FKB"/>
</field>
<field name="myb">
<!-- the field myb is mapped over the column FKB which is a foreign key
on the PKB column, and corresponds also to the idb field-->
<extension vendor-name="speedo" key="target-foreign-keys" value="PKB=FKB"/>
</field>
</class>
<class name="B"/>
<field name="myid" primary-key="true">
<extension vendor-name="speedo" key="sql-name" value="PKB"/>
</field>
</class>



Note: The primitive field can compose the identifier of the current class.

class A {
String ida1;
String ida2;
B myb;
...
}
class B {
String myid
...
}

#the .jdo file
<class name="A"/>
<field name="ida1" primary-key="true">
<!-- the field ida1 is mapped over the column PKA1 -->
<extension vendor-name="speedo" key="sql-name" value="PKA1"/>
</field>
<field name="ida2" primary-key="true">
<!-- the field ida2 is mapped over the column PKA2 -->
<extension vendor-name="speedo" key="sql-name" value="PKA2"/>
</field>
<field name="myb">
<!-- the field myb is mapped over the column PKA2 which is a
foreign key on the PKB column, and corresponds also to the ida2 field -->
<extension vendor-name="speedo" key="target-foreign-keys" value="PKB=PKA2"/>
</field>
</class>
<class name="B"/>
<field name="myid" primary-key="true">
<extension vendor-name="speedo" key="sql-name" value="PKB"/>
</field>
</class>



Note: The possible couples are the following:


Does Speedo support my database ?

Speedo supports several relational databases (supported databases). Speedo is based on JORM, and uses in particular RdbAdapter for each supported database. A RdbAdapter permits to take in account non conformance of JDBC driver/database to the JDBC/SQL standards. Then if your database is not already supported you can easily write a RdbAdapter. An RdbAdapter is a short class about 25 java lines. JORM provides a RdbAdaper tester permiting to find the conformance problem, to solve and to verify that your adapter works fine. Your are welcomed to contribute to the adapter suite for adding new database support. Download the RdbAdapter developpement kit
To store your persistent classes in other support type, you have to write a JORM Mapper. Contact the JORM team for more information.

Does Speedo permit concurrent database accesses ?
Does Speedo supports clustering ?

Yes, Speedo supports clustering and concurrent database accesses (read or write). For more details read the Concurrency Management chapter in the usermanual.

How to desactivate caching ?

Read the Caching chapter in the usermanual.

Out of memory problem during enhancement

This problem can occur if you have lot of persistent classes. So the simple solution is to increase the JVM memory used by Ant. You have to define the 'ANT_OPTS' environnement variable as the following example:

on linux system:

export ANT_OPTS="-Xms140m -Xmx140m -Xss256k"

on windows system:

set ANT_OPTS=-Xms140m -Xmx140m -Xss256k

For instance if you want to run the speedo test, you need 130Mega bytes of memory for the compilation step.

How to redeploy my application linked with the Speedo resource adapter ?

In a J2EE context, Speedo can be integrated as a resource adapter.
When you try to redeploy your application using speedo within your J2EE server, you can face ClassCast exception. Indeed, the speedo resource adapter keeps references to persistent classes you used before redeploying. In this case you have to restart your J2EE server.

Speedo provides a clean method to avoid these problems. Once you've stopped your application, you call the clean method via the Speedo JMX console (PMF section of the console). Then you can upload your modified application without facing ClassCast exception and without restarting your J2EE server.

Where is my pm.attachCopy() method?

    In the final version of JDO2, the attachCopy and attachCopyAllmethods vanished. To attach a detached object, you just have to call the makePersistent method on the persistent manager.

I want to use Speedo in JOnAS

    This is the procedure to use a specific Speedo release in JOnAS:
  1. Download the JOnAS release you want to work with from the jonas web site.
  2. Download the Speedo release from the speedo web site.
  3. Install JOnAS and configure it for Speedo:
  4. Check jonas is correctly setup with jonas start
  5. Install Speedo:
  6. Configure the speedo-jdo.properties file in the etc directory of speedo:
  7. Copy this speedo-jdo.properties file to JONAS_ROOT/conf directory
  8. Go to the jonas admin console and deploy speedo_for_jonas_ra.rar as a resource adapter
    Speedo has been succesfully made available in JOnAS.

   You can check all went right using the speedo bank example:
  1. Change to the speedo_install/examples/bank directory
  2. Build the bank example typing ant
  3. Deploy the example in JOnAS typing ant deploy (JONAS_ROOT and JONAS_BASE variables must be set)
  4. Create the data structure in your database typing ant createDataStruct (you must set the speedo.dbconf variable of the build.xml file to the location of your MyDatabaseSQL1.properties file)
  5. Check in the jonas admin console that the bank application has been deployed as an ejb jar (if it is not the case, deploy it via the admin console)
  6. In the speedo_install/examples/bank directory, type ant run_in_jonas to get instructions to test the bank application in JOnAS, you have to execute the following commands: