Leon Messerschmidt wrote:
>
> Hi
>
> There is some functionality which might be useful to the generated peer
> classes, but I might need some slight changes to the table/column mapping
> classes, so that columns know if they are used as foreign keys in other
> tables.
>
> My proposal is for 1:M relations: Basically the idea is that if a table
> (call it A) has a column that is used as a foreign key in another table
> (call it B) the A data object will have a method that does a query and
> return a vector with related B data objects. The other way round B will
> have a method that returns it's master A object.
>
> To avoid overhead and the unnecessary loading of objects from database the
> query is only done once the method is called. In other words only when A's
> getBobjects() method is called the query is actually executed and the B
> objects loaded. In fact these methods are merely utility methods that does
> queries for that particular table's relations for you...
>
> I haven't given this much though yet, and there might still be issues that
> will need to be solved. It might take me some time to get started on this.
>
> Is this feasible at all? Is it worth the trouble? Any other thoughts?
>
> ~ Leon
Hello,
In a case like the following (simplified):
CREATE TABLE CUSTOMER_TRANSACTION(
TRANSACTION_ID INTEGER NOT NULL,
CUSTOMER_ID INTEGER NOT NULL,
PRIMARY KEY (TRANSACTION_ID),
FOREIGN KEY (CUSTOMER_ID)
REFERENCES CUSTOMER(CUSTOMER_ID)
)
;
CREATE TABLE CUSTOMER(
CUSTOMER_ID INTEGER NOT NULL,
CUSTOMER_DESCRIPTION VARCHAR(255),
PRIMARY KEY (CUSTOMER_ID)
)
;
(excuse the pseudo-mysql, that's the basic idea anyway...)
I'd like to do a select in the generated CustomerTransactionPeer and get
back a vector of CustomerTransactionMaster (name??) objects that just
wrap the other two objects. NGMBT would generate a class like this:
CustomerTransactionMaster
---------------------
getTransactionId()
getCustomerId()
getCustomerDescription()
etc...
Some questions:
Is this out of scope to your proposal for more functionality in NGMBT?
As I recall, something like the following was discussed at the
turbine/scarab confab:
BusinessLogic (hand coded class)
DataObject (generated from schema, 1 class:1 table)
Peer (generated from schema, 1 class: 1 table)
Is it worthwhile or just redundant to throw an optional DataObjectMaster
in between DataObjects and a BusinessLogic object? Is a
DataObjectMasterPeer needed to lazily fill in the objects related by
foreign keys? What's a good design for using the peer model that
insulates business logic from future (de)normalization of an underlying
sql structure more than having a 1:1 class to table design?
Regards,
~Eric
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]