db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dyp <...@brainhouse.ru>
Subject Please help on OJB+Xdoclet+Torque
Date Wed, 15 Jun 2005 18:38:31 GMT
Hello, all.
We are developing web-application for cocoon with ojb and trying to
generate all ojb and sql stuff from the source java files.
We use ojb 1.0.1, xdoclet-ojb-module-1.2.2, torque-gen-3.1.1 and mysql.

== PROBLEM ==
The plot:
We have java classes with xdoclet tags. From those we generate
repository_user.xml (for ojb) and db-schema.xml (for torque) via ant
tasks for xdoclet-ojb-module.
Then torque-generator generates *.sql for database and repository*.xml
files for OJB from db-schema.xml.

Java classes:
User.java:

/**

 * @ojb.class table="user"

 *            include-inherited="true"

 * @ojb.field name="countryId"

 *            column="countryId"

 *            jdbc-type="BIGINT"

 */

public class User {

  /**

   * @ojb.field column="uid"

   *            jdbc-type="BIGINT"

   *            autoincrement="database"

   *            primarykey="true"

   *            nullable="false"

   *            default-fetch="true" 

   */

  private Long uid;

  /**

   * @ojb.field column="email"

   *            jdbc-type="VARCHAR"

   *            length="255"

   *            default-fetch="true"

   */

  private String email;

  /**

   * @ojb.reference auto-retrieve="true"

   *                foreignkey="countryId"

   *                database-foreignkey="true"

   */

  private Country country = new Country();

}


Country.java:

/**

 * @ojb.class table="country"

 */

public class Country {

  /**

   * @ojb.field column="id"

   *            jdbc-type="BIGINT"

   *            autoincrement="database"

   *            primarykey="true"

   *            nullable="false"

   *            default-fetch="true"

   */

  private Long id;


  /**

   * @ojb.field column="name"

   *            jdbc-type="VARCHAR"

   *            length="255"

   *            default-fetch="true"

   */

  private String name;



>From these source files XDoclet generates:
1. absolutely correct repository_user.xml. (with reference-descriptor
and foreign-key ref)
2. project-schema.xml for Torque is unusable because of the <database>
descriptor: the attribute defaultIdMethod="..." not generated, although
attributes for fields marked with @ojb.field autoincrement="database"
are generated correctly: autoIncrement="true".

Question: why attribute defaultIdMethod not generated? Without it the
generated schema is useless for Torque. It needs this attribute in
schema to generate AUTO_INCREMENT for fields marked as <column ..
autoIncrement="true" /> in schema.
Through the xdoclet-module source i've learnt that XDoclet (.xdt files)
wasn't designed to generate this attribute. Sob.
How can any get the working schema file from xdoclet for torque?

Further..
After xdoclet ojbdoclet and torqueschema ant tasks we have:
project-schema.xml
repository_user.xml

We run the torque-gen build ant targets for producing *.sql files and
repository*.xml files.
1. *.sql files are useless because of missing attribute
defaultIdMethod="..." in <database> in project-schema.xml.
2. repository files for ojb are incorrect because of:
repository.xml:
- torque generates jdbc-connection-descriptor with our properties and
with nested <sequence-manager> element. How can we specify this
sequence-manager for torque? The default generated
(SequenceManagerHighLowImpl) is unneeded. We want
SequenceManagerNativeImpl with our custom attributes. How could we
specify it for Torque? And the generated jdbc-connection-descriptor is
default, but we don't want it to be default. I've found that this is
coded in MainRepository.vm in torque, but cannot find how to provide a
custom secuence-manager. Via build.properties? via changing this template?
repository_project.xml:
- torgue doesn't generates attribute access="anonymous" for anonymous
fields and reference-descriptor for foreign-keys. Why?
For now we just overwrite this repository_project.xml from torque with
correct repository_project.xml form xdoclet-module.
Why Torque doesn't generate the correct code?


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


Mime
View raw message