You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Steve Lukshides <lu...@us.ibm.com> on 2003/03/27 17:14:43 UTC
Torque project references, stability, reliability
Hi,
Does anyone know of a source for project references that discuss success
and/or failure using Torque? What are your personal impressions regarding
Torque's stability, performance and reliability and on what size of project
are you using it?
Regards,
Steve Lukshides
Sr. I/T Specialist, IBM Global Services
1475 Phoenixville Pike, West Chester, PA 19380
Phone: 610-989-0340
Voice Mail: 610-578-2385 IBM Tie Line: 873-2385
Email: lukshide@us.ibm.com
Re: foreign-key problems
Posted by Stephan Wiesner <st...@stephan-wiesner.de>.
Okay, found the problem. Have to define it the other way round...
Stephan
Stephan Wiesner wrote:
> Hi list, I have a problem with foreign-key elements. Below is my tiny
> database definition and I can generate the SQL, if I remove the
> foreign-key element. With it, I get a nullpointer exception, though.
> Can anybody, please, enlighten me?
>
> java.lang.NullPointerException
> at
> org.apache.torque.engine.database.model.Database.doFinalInitialization(Database.java:444)
>
>
>
> <database
> name="immorate"
> defaultIdMethod="idbroker">
>
> <table name="customer" description="Customer of Bank">
> <column
> name="c_id"
> required="true"
> primaryKey="true"
> type="INTEGER"
> description="Customer Id"/>
> <column
> name="lastname"
> required="true"
> type="VARCHAR"
> size="100"
> description=""/>
>
> </table>
>
>
> <table name="account" description="Bank account">
> <column
> name="accountnumber"
> required="true"
> primaryKey="true"
> type="INTEGER"
> description="Account number"/>
>
> <foreign-key foreignTable="customer"
> >
> <reference
> local="c_id"
> foreign="c_id"/>
> </foreign-key>
> </table> </database>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>
Enforcing 'Not Null' Columns
Posted by Stephan Wiesner <st...@stephan-wiesner.de>.
Hi list,
when I create a table with columns set to 'Not Null' the generated Java
code does not enforce this in any way. When I initialize an object
without setting all required attributes and then try to store it, I get
an SQL exception. Wouldn't it be more efficient to test this in the Java
class, instead of relying on the database?
Stephan
foreign-key problems
Posted by Stephan Wiesner <st...@stephan-wiesner.de>.
Hi list, I have a problem with foreign-key elements. Below is my tiny
database definition and I can generate the SQL, if I remove the
foreign-key element. With it, I get a nullpointer exception, though.
Can anybody, please, enlighten me?
java.lang.NullPointerException
at
org.apache.torque.engine.database.model.Database.doFinalInitialization(Database.java:444)
<database
name="immorate"
defaultIdMethod="idbroker">
<table name="customer" description="Customer of Bank">
<column
name="c_id"
required="true"
primaryKey="true"
type="INTEGER"
description="Customer Id"/>
<column
name="lastname"
required="true"
type="VARCHAR"
size="100"
description=""/>
</table>
<table name="account" description="Bank account">
<column
name="accountnumber"
required="true"
primaryKey="true"
type="INTEGER"
description="Account number"/>
<foreign-key foreignTable="customer"
>
<reference
local="c_id"
foreign="c_id"/>
</foreign-key>
</table>
</database>
Re: Q: Joins using Criteria ?
Posted by David Hainlin <dh...@attbi.com>.
Greetings,
One way to approach this is to create a view which joins the req'd
tables and then define the torque object based on the view.
Works pretty well but there may be other ways too...
David
goffredo wrote:
>Hi All,
>
>I have been reading the documentation on using Criteria objects with Torque,
>but can't find an example of a join of say three or four tables that returns
>all the columns of the three or four tables that satisfy the conditions of the
>query. The examples illustrate multiple joins, but retrieve information from
>only one of the tables in the join, because the doSelect() method is attached
>to Peer classes only. Or am I expected to add tables to my database to handle
>this kind of situation?
>
>I am not sure from reading the documentation if the use of Criteria is designed
>to replace SQL ... or if Criteria form a more limited subset of SQL.
>
>Regards
>Goffredo
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>For additional commands, e-mail: torque-user-help@db.apache.org
>
>
>
>
RE: Joins using Criteria ?
Posted by Chris K Chew <ch...@fenetics.com>.
Criteria objects will replace SQL in all but the most extreme cases. Take
another look at the Peers Howto
(http://db.apache.org/torque/peers-howto.html), specifically in the "Joins
And Linking Objects" section. I will repeat the concept below because
sometimes it helps to hear it another way...
If you simply want to pull a field from a related object, use the
<foreign-key> tag in your schema to relate them. When generating your peers
and classes, this will provide a get<RelatedObject>() or
get<RelatedObject>s() in the objects which you can use to access the foreign
object, and thus the foreign field.
For example, I have a Customer and a BuilderRegistration. BR's are related
to C's by CUSTOMER_ID. Say I want the name of the customer that registered
a particular builder:
Schema:
=================================================================
<table name="BUILDER_REGISTRATION">
...
<foreign-key foreignTable="CUSTOMER">
<reference local="CUSTOMER_ID" foreign="CUSTOMER_ID"/>
</foreign-key>
</table>
Criteria:
=================================================================
Criteria crit = new Criteria();
crit.add(BuilderRegistrationPeer.ID,builderRegId);
Usage:
=================================================================
List results = BuilderRegistrationPeer.doSelect(crit);
BuilderRegistration breg = (BuilderRegistration)results.get(0);
System.out.println("BREG " + builderRegId + " belongs to Customer " +
breg.getCustomer().getName());
I hope this helps,
Chris
> From: goffredo
>
> I have been reading the documentation on using Criteria objects
> with Torque,
> but can't find an example of a join of say three or four tables
> that returns
> all the columns of the three or four tables that satisfy the
> conditions of the
> query. The examples illustrate multiple joins, but retrieve
> information from
> only one of the tables in the join, because the doSelect() method
> is attached
> to Peer classes only. Or am I expected to add tables to my
> database to handle
> this kind of situation?
>
> I am not sure from reading the documentation if the use of
> Criteria is designed
> to replace SQL ... or if Criteria form a more limited subset of SQL.
>
> Regards
> Goffredo
Q: Joins using Criteria ?
Posted by goffredo <go...@twibble.org>.
Hi All,
I have been reading the documentation on using Criteria objects with Torque,
but can't find an example of a join of say three or four tables that returns
all the columns of the three or four tables that satisfy the conditions of the
query. The examples illustrate multiple joins, but retrieve information from
only one of the tables in the join, because the doSelect() method is attached
to Peer classes only. Or am I expected to add tables to my database to handle
this kind of situation?
I am not sure from reading the documentation if the use of Criteria is designed
to replace SQL ... or if Criteria form a more limited subset of SQL.
Regards
Goffredo