RE: Same Table name different Node -> works?

From: Gentry, Michael \(Contractor\) ("Gentry,)
Date: Thu Mar 10 2005 - 16:27:22 EST

  • Next message: Gentry, Michael \(Contractor\): "RE: Same Table name different Node -> works?"

    You can have a your User in a relationship. To fetch your user, do
    something like:

    final Expression expression = Expression.fromString("username =
    Map parameter = new HashMap(1);
    parameter.put("username", username);
    Query query = new SelectQuery(User.class,
    List list = dataContext.performQuery(query);

    Of course, that doesn't take any security into account. The refresh
    option will just ensure it is read from the DB again, even if already
    cached in memory.


    -----Original Message-----
    From: Fredrik Liden []
    Sent: Thursday, March 10, 2005 4:12 PM
    Subject: RE: Same Table name different Node -> works?

    Oh I think I got it now!

    As long as I don't include the USER table in any relationship I shouln't
    have any problems with caching. I'll just run a query to fetch the
    information and this query could use query.setRefreshingObjects(true).

    -----Original Message-----
    From: Gentry, Michael (Contractor) []

    Sent: Thursday, March 10, 2005 12:10 PM
    Subject: RE: Same Table name different Node -> works?

    I think I would have two data nodes in the second application: one would
    point to its primary data and the other would point to the first
    application's extensive user/login information. Then model things
    naturally (I don't think you'd need two "User" entities or tables). I
    wouldn't go through the trouble of trying to synchronize a table across
    multiple databases if you can avoid it.

    Also, keep in mind you can form relationships across DataNodes if you
    need to. So one entity could have a join to the User entity, even
    though they reside in different databases. Faulting works fine. The
    big "gotcha" that I know of in this situation is you can't do queries
    (using a single Expression) across both tables at the same time. But
    for something like a User object, you'd probably keep ahold of that in a
    session variable/etc and you could just call setUser(session.getUser())
    methods whenever needed.

    Read-only has nothing to do with caching. You can explicitly force a
    refetch on your query using a query.setRefreshingObjects(true); in your


    -----Original Message-----
    From: Fredrik Liden []
    Sent: Thursday, March 10, 2005 2:49 PM
    Subject: RE: Same Table name different Node -> works?

    Thanks for respoding Michael.

    We have two different applications located on different servers.
    One app has extensive user information and login information that I want
    to use in the second app as well.

    I was thinking of creating a trimmed down version of a user table in the
    second app and synch it with the first one on a periodical basis, back
    and forth.

    My thought was to have one Node pointing to the first app and a second
    Node pointing to the second app. And both containing a table called USER
    in their map, keeping the first Node's USER table read-only (and
    hopefully prevent caching?) and then copy it's user info over to the
    second user table. Calling both tables USER.

    The reason I separate them is because I'm afraid that when user info
    changes in the first app (ouside of Cayenne) the context won't recognize
    the changes.

    I guess the easiest thing would be to just add one character to
    differentiate them :)

    Do you have any advice on a better solution?



    -----Original Message-----
    From: Michael Gentry (Yes, I'm a Contractor)
    Sent: Thursday, March 10, 2005 11:29 AM
    Subject: RE: Same Table name different Node -> works?

    I use the same table/Java name in one of my models, but across separate
    DataDomains (the name is unique in the DataNode). I don't believe you
    duplicate it within the same DataNode, as Cayenne will not know which DB
    connection to use. I would doubt you could duplicate it within two
    DataNodes under a common DataDomain.

    Can I ask why you are wanting to do this? There might be a better
    to your problem.


    -----Original Message-----
    From: Fredrik Liden []
    Sent: Thursday, March 10, 2005 12:53 PM
    Subject: Same Table name different Node -> works?


    Is it possible to use the same table name under different Notes?
    Can they be qualified somehow with the Node info?
    I'm trying to find this on the list but can't seem to find the answer.



    This archive was generated by hypermail 2.0.0 : Thu Mar 10 2005 - 16:27:26 EST