RE: Getting info across databases...

From: Michal Kozlowski (mkozlowsk..MVProjects.com)
Date: Tue Nov 09 2004 - 10:07:04 EST

  • Next message: Bryan Lewis: "Re: Getting info across databases..."

    Andrus,

    Sorry, I replied to you the first time, and not the list.

    Okay the first problem I fixed right after sending it to you, with getUnitId(). Hmm okay the CACHING was me trying to see how I can speed things up a bit, so I'll remove it, oh I didn't know they cached between different instances, thanks for the heads up. The code I sent was an experiment of me just trying to see if I can get information, so 4 was a number I knew worked.

    Hmm, I honestly have no idea what else can cause this problem, because there are no NULL fields in the Discipline table under ExternalId. So to clarify my code looks like this, from Discipline...

      public List getUserList()
      {
        Expression qualifier = ExpressionFactory.matchDbExp("UnitId", getUnitId());

        SelectQuery query = new SelectQuery(User.class, qualifier);
        return getDataContext().performQuery(query);
      }

    and getUnitId() returns the value of ExternalId from the table, that kinda confusing. Short and sweet and I will keep it there until I can make heads or tails of the problem.

    Just a quick question it seems like all the other queries are using parameters, this one isn't. Hmm is there anything else I can do to help out, I feel I'm doing something wrong b/c you couldn't reproduce the problem. I'm using 1.0RC2 and java 1.4.2_06.

    Thanks a million for the hints, and I hope we could figure the problem out.

    Cheers
    Mike

    -----Original Message-----
    From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Sent: Monday, November 08, 2004 6:33 PM
    To: cayenne-use..bjectstyle.org
    Subject: Re: Getting info across databases...

    Hi Michal,

    I tried building a quick prototype based on your mapping, and I
    couldn't reproduce the problem. But the code in your custom
    "getUserList" method looks suspicious:

    > Expression qualifier = ExpressionFactory.matchDbExp("UnitId", new
    > BigDecimal(4));

    Why is "4" hardcoded?

    > query.setName("UserSelect");
    > query.setCachePolicy(GenericSelectQuery.LOCAL_CACHE);

    These two lines may definitely cause the problem. Cache is keyed using
    query names. So if you used "UserSelect" name for another query
    elsewhere things will get hairy... Even among two different instances
    of Discipline you'll likely end up with incorrect results, so you have
    to use the key unique for each Discipline instance.

    Finally I am still confused about how you ended up having a piece of
    SQL "WHERE t0.UnitId = NULL" (even if the parameter is indeed NULL, it
    would've been translated as "WHERE t0.UnitId is NULL"). Strange...

    Andrus

    On Nov 8, 2004, at 2:58 PM, Michal Kozlowski wrote:
    > Hi,
    > Firstly thanks again for all the help you guys are offering me, and
    > for the great product. I ran into a simple problem, which normally
    > works but for some reason it don't work for this situation.
    >
    > I have 2 tables, they are on separate databases, so I have 2
    > DataNodes, this normally isn't a problem as I have done this a couple
    > of times. In this case I have one table Discipline that is related to
    > a table(view) _UserInfo. The relation is Discipline->ExternalId =
    > _UserInfo->UnitId. My Object Entities are Discipline and User, and I
    > create a relationship called UserList and Discipline respectively to
    > navigate the relationship. Problem is it doesn't work when I go
    > Discipline.getUserList I get an empty list back and I should, the
    > reason is that is create this query which have errors
    >
    > INFO QueryLogger: SELECT t0.Disabled, t0.FirstName, t0.LastName,
    > t0.LoginName, t0.UserId, t0.UnitId FROM dbo._UserInfo t0 WHERE
    > t0.UnitId = NULL
    > INFO QueryLogger: === returned 0 rows. - took 0 ms.
    > INFO QueryLogger: +++ no commit - transaction controlled externally.
    >
    > The NULL field should not be there, it is a valid field that is set to
    > not be NULL, I wrote a overloading function for getUserList that
    > looks like this and it works
    >
    > public List getUserList()
    > {
    > Expression qualifier = ExpressionFactory.matchDbExp("UnitId", new
    > BigDecimal(4));
    >
    > SelectQuery query = new SelectQuery(User.class, qualifier);
    > query.setName("UserSelect");
    > query.setCachePolicy(GenericSelectQuery.LOCAL_CACHE);
    > query.setRefreshingObjects(false);
    >
    > List disciplineUsers = getDataContext().performQuery(query);
    > return disciplineUsers;
    > }
    >
    > So my question is what am I doing wrong in my cayenne information
    > which I am attaching as well.
    >
    > Secondly how do I change the logging level of a query, I tried setting
    > this up but I can't figure out were to put the cayenne-log.properties
    > file. I running this as a tapestry application under Tomcat. Thanks
    > for all the information and support.
    >
    > Cheers
    > Mike
    > <Actual DataMap.map.xml><Actual
    > DataNode.driver.xml><cayenne.xml><Forecast DataMap.map.xml><Forecast
    > DataNode.driver.xml>



    This archive was generated by hypermail 2.0.0 : Tue Nov 09 2004 - 10:08:33 EST