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 dyp <dy...@brainhouse.ru> on 2005/06/15 20:38:31 UTC

Please help on OJB+Xdoclet+Torque

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


ER: Please help on OJB+Xdoclet+Torque

Posted by Thomas Fischer <fi...@seitenbau.net>.



Hi,

I am afraid to say this is the first time I have heard about the
capabilities of Torque you describe. It has neither been in the users
mailing list nor in the dev mailing list in the last six months, So my
guess would be very little users use them.
This would mean two things
- probably, these features will not be very well tested
- it is unlikely that you will get help on the users list

So I regret to say that it will be mostly up to you to cope with the
problems you encounter :-(
However, if you are able to remove any bugs, please open up a scarab issue
on them so that they can be considered in future Torque releases.
Also, it is not very unusual for Torque users to modify the velocity
templates to get what you want.

 Hope this has clarified the situation a bit,

       Thomas

dyp <dy...@brainhouse.ru> schrieb am 15.06.2005 20:38:31:

> 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: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


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