Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Odd use case

Comment inline:

Laird Nelson wrote:
On Mon, Jul 13, 2009 at 11:47 AM, Tom Ware <tom.ware@xxxxxxxxxx <mailto:tom.ware@xxxxxxxxxx>> wrote:

     If I am reading correctly, the relationship between Document and
    GLaAcounts is not fully represented in the database (the
    effectiveDate field is not in any table).  Is that correct?


Yes. A Document has 4/5 of a foreign key :-) to a GLAccount. The remaining component is a fiscal year.

Under normal circumstances--which these aren't!--I'd introduce a join table, that would associate a Document on the "left" side with a GLAccount on the "right" side, adding a fiscal year field as an additional property of the join relationship (ASCII art follows):

Document      JoinTable      GLAccount
========      =========      =========
pk <--- docPK four fks ---> four pks
              fiscal yr ---> fiscal yr

Instead what I have is this (ASCII art):

Document      GLAccount
========      =========
pk            fiscal yr
four fks ---> four pks

...and effectively cannot change the database.
    How are GLAAcounts and Documents inserted into the database?  Are
    they read-only?


Nope.
    Unless I am mistaken above, I do not think there is anything as
    simple as what you suggest as a solution.  The things that come to
    mind that might help:

    - In JPA you could use named native queries and result set mappings
    to somehow buildyour objects


Yeah; was looking for some sort of sugar to help here.
    - EclipseLink allows customization of the queries that are used to
    traverse mapping.  Depending on exactly what you are trying to
    acheive, you may be able to use a DescriptorCustomizer to access the
    query that traverses the Document->GlaAccounts mapping and ammend it
    to accept some additional criteria.


Interesting; will look.

Take a look here:

http://wiki.eclipse.org/Configuring_a_Relational_Descriptor_%28ELUG%29

And look at:

"How to Configure Custom SQL Queries for Basic Persistence Operations Using Java"

In that section, there are some pointers to the methods you might use to use a SQL String. In addition to that you should be able to use the getter methods (like getReadAllQuery()) to get a handle on the EclipseLink query object - which can then be changed if necessary.

The trick is going to be how to get the fiscal year data into those queries.

-Tom


Thanks,
Laird


------------------------------------------------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top