Re: Required Relations?

2007-03-23 Thread Tobias . Schoessler
you do this on the database level, when creatig the tables, by defining the foreign keys to be mandatory. e.g. NOT NULL the exact syntax depends on your database. cayenne picks up these constraints and checks the values to be set before committing. Roja Buck <[EMAIL PROTECTED]> wrote: All,

Re: Ordering by Primary/Foreign Keys

2007-03-23 Thread Mike Kienenberger
For primary key, you can use "db:" + YourEntity._PK_COLUMN For a foreign key, you could do the same, but it'd be cleaner to use the objRelationship name. On 3/23/07, Michael Lepine <[EMAIL PROTECTED]> wrote: In my application, I have a few queries that I've created with the SelectQuery class.

Re: Ordering by Primary/Foreign Keys

2007-03-23 Thread Tobias . Schoessler
I think you have to manually map the fk/pk as an attribute. then cayenne knows the field for ordering. when reverse engineering a database cayenne does not create attribute mappings for pks and fks. Michael Lepine <[EMAIL PROTECTED]> wrote: In my application, I have a few queries that I've crea

Re: Required Relations?

2007-03-23 Thread Mike Kienenberger
The mandatory nature of the relationship is based on the mandatory nature of the underlying DB attributes. Ie, if PAINTING.ARTIST_ID is mandatory, then the relationship Painting.artist is also mandatory and must not be null. On 3/23/07, Roja Buck <[EMAIL PROTECTED]> wrote: All, I am a littl

Ordering by Primary/Foreign Keys

2007-03-23 Thread Michael Lepine
In my application, I have a few queries that I've created with the SelectQuery class. In some instances, I'd like to order the results by the primary or foreign keys in the table using the addOrdering() method. I have not found a way to do this. I believe I get an error that the column does not ex

Required Relations?

2007-03-23 Thread Roja Buck
All, I am a little new to databases so I apologise if this query is particularly incompetent. I have created a series of tables all of which are related to one central table with that central table having relations of one to many with the rest of the tables. The problem I have however is that I

Re: How do I return a record count?

2007-03-23 Thread Frank
Thanks Mike, that did the trick. List list = context.performQuery(query); Map row = (Map)list.get(0); String cnt = row.get("cnt").toString(); Regards, Frank - Original Message - From: "Mike Kienenberger" <[EMAIL PROTECTED]> To: Sent: Friday, March 23, 2007 11:13 AM Subject: Re: How d

Re: How do I return a record count?

2007-03-23 Thread Mike Kienenberger
Sounds right. I haven't used named queries so I wasn't aware of how they are configured. If that's the case, what sql output do you see in the logs? Here's some sample code that might be helpful. It doesn't do quite the same thing, but it's pretty close in structure and data returned. pri

Re: How do I return a record count?

2007-03-23 Thread Frank
Fetch DataObjects is unchecked. Does this default to fetch DataRows? Frank - Original Message - From: "Mike Kienenberger" <[EMAIL PROTECTED]> To: Sent: Friday, March 23, 2007 11:01 AM Subject: Re: How do I return a record count? Did you set the query to fetch DataRows (Maps) instea

Re: How do I return a record count?

2007-03-23 Thread Mike Kienenberger
Did you set the query to fetch DataRows (Maps) instead of DataObjects (Entities)? On 3/23/07, Frank <[EMAIL PROTECTED]> wrote: Hello, I have a named query defined as: SELECT COUNT(ticketId) AS cnt FROM tickets WHERE ticketClosed = 0 This is not working, how do I get the count returned? NamedQue

How do I return a record count?

2007-03-23 Thread Frank
Hello, I have a named query defined as: SELECT COUNT(ticketId) AS cnt FROM tickets WHERE ticketClosed = 0 This is not working, how do I get the count returned? NamedQuery query = new NamedQuery("openTicketsQuery"); List records = context.performQuery(query).; String cnt = records.get(0).toString()

Re: Cayenne Question

2007-03-23 Thread Andrus Adamchik
Hi Prashant, Note that Cayenne user support is done via the mailing list, as it allows us to better share the community knowledge. I am ccy'ing the question to the list. Please feel free to continue this discussion on the list: http://cayenne.apache.org/mailing-lists.html On Mar 23, 200