You may wish to check out this link which will point you at a variety of options for working with OJB including xdoclet:
http://db.apache.org/ojb/howto-build-mappings.html
The xdoclet task for ojb is in the contrib directory of the ojb source download. I have heard that it will eventually become part of the xdoclet distro, but this has not yet happend as far as I know.
The reason I chose xdoclet is cause It will generate, the JDO descriptors, the torque schema and the repository.xml from a class that looks like this:
/**
* The actual data that needs to be persisted for a location.
*
* @ojb.class * @jdo.persistence-capable
*/
public class LocationBase implements Location {
/**
* @ojb.field primarykey="true"
*/
Integer id;
/**
* @ojb.field length="40"
*/
String country;
/**
* @ojb.field length="60"
*/
String stateOrRegion;
/**
* @ojb.field length="60"
*/
String subRegion;
/**
* @ojb.field length="60"
*/
String city;
(Rest of class is irrelevant)
in my Ant build I use a target like:
<!-- ==================== Xdoclet OJB stuff ================================== -->
<target name="repository-files" depends="init">
<taskdef name="ojbdoclet" classname="xdoclet.modules.ojb.OjbDocletTask">
<classpath refid="compile.classpath"/>
</taskdef>
<ojbdoclet destdir="${build.home}/WEB-INF/classes/">
<fileset dir="./src" excludes=".nb*"/>
<ojbrepository destinationFile="repository_user.xml"/>
<torqueschema databaseName="fdbtest2" destinationFile="project_schema.xml"/>
</ojbdoclet>
</target>
I get an entry for Country that looks like this in my repository_user.xml file:
<field-descriptor
name="country"
column="country"
jdbc-type="VARCHAR"
length="40"
>which matches this entry in my project_schema.xml:
<column name="country"
javaName="country"
type="VARCHAR"
size="40"
/>This puts the information in one place. which is very nice and easy to maintain.
-Gus
Emmanuel Dupont wrote:
All,
What is the best solution to control the field length of a JSP application with OJB.
The repository. Xml doesn't contain any information about the database field length.
Anyway if it would do it, I would have the same trouble. All the jdo attribute I use are String, etc.and in database I have Varchar(20), Varchar (4) etc..
Any help, please...
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
