db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thoralf Rickert" <thoralf.rick...@cadooz.de>
Subject AW: CamelCase, Object Population and Relational Selects
Date Wed, 07 Dec 2005 08:28:07 GMT
> Question 1: Is there a way to maintain the CamelCase of the tables 
> inside of the torque classes? ex: If I have a table named 
> accountTypes I get classes such as AccounttypesBase, AccounttypesPeer
> and Accounttypes. 
> Is it possible to get proper casing out of Torque like 
> AccountTypesBase?

See docs:
<table name="accountTypes" javaName="AccountType">
...
</table>


> Question 2: We are considering integrating with Torque and the object
> model it creates more tightly. Currently we don't use the generated
> classes much at all besides querying the database then pulling the
> information out of the objects and translating it into something more
> usable from a java perspective.

Hmmm, perhaps Torque is not what you need. But I'm not sure if there is
a framework that puts your database tables in a "usable java
perspective". Torque isn't able to understand the background of your
database design. 

> [...]
> example:
> say there is a OM class called Account that relates to Company in the 
> database. Is there a way to get an Account object with a List 
> of Company 
> instead of a List of Account each one containing a Company object.

I'm a little bit confused about that example. Has Account a foreign key
to Company...

Then there will never be more then one company for one account.

... or is there something like a link table between Account and Company
(f.e. AccountCompanyAssignment)?

Then make a select with the account in the AccountCompanyAssigment and
join the companies. You will get a list of AccountCompanyAssignments.
Extract the companies from that list in a wrapper method in
AccountCompanyAssignmentPeer and return the list of companies:

public static List getCompanies(Account account) throws Exception {
  Criteria criteria = new Criteria();
  criteria.add(ACCOUNT_ID, account.getID());
  criteria.addGroupByColumn(COMPANY_ID);
  List result = doSelectJoinCompany(criteria);
  List companies = new ArrayList();

  for (AccountCompanyAssigment assignment : result)
companies.add(assigment.getCompany());
  
  return companies;
}



> Question 3: I see that there is a way to join against related tables, 
> and also a way to join against all related tables except a 
> certain one. 
> Perhaps it's a gross oversight on my behalf but is there a 
> way to join 
> against ALL relationships?

Create your own method by copying a doSelectJoinAllExcept*() method and
add the excepted related table. It's not difficult. I think there was
something in the documentation about this.




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


Mime
View raw message