Cross Database Query

Posts   
 
    
Posts: 33
Joined: 05-Feb-2005
# Posted on: 08-Feb-2005 05:21:54   

I tried using generated Entities from two different databases in the same query and got an error saying one of the objects didn't exist. I looked at the SQL code generated by the DQE and noticed the table references weren't prefixed by the database name. Is there a way to get this to work?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Feb-2005 09:33:07   

THis only works in adapter at the moment, not in selfservicing. Multiple catalog support is coming with the upgrade currently in development, scheduled to go beta at the end of february.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 33
Joined: 05-Feb-2005
# Posted on: 08-Feb-2005 20:41:52   

Ok, so I'm trying to get this to work in the adapter model, and I have a question about FieldPersistenceInfo. In the following code, where do I get the FieldPersistenceInfo for params 2 and 4?


notAlreadyMappedFilter = new FieldCompareSetPredicate(
                                                                    Quotit.DB.QUOTIT.FactoryClasses.EntityFieldFactory.Create(BrokerFieldIndex.BrokerId),
                                                                    null,
                                                                    Quotit.DB.Admin.FactoryClasses.EntityFieldFactory.Create( CustomerIproAccountsImportFieldIndex.IproBrokerId),
                                                                    null,
                                                                    SetOperator.Exist,
                                                                    null,
                                                                    true);

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Feb-2005 21:15:37   

That's been done for you by the DataAccessAdapter class. in fact, all persistence info is filled by the DataAccessAdapter class, you just specify null simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Posts: 33
Joined: 05-Feb-2005
# Posted on: 08-Feb-2005 23:00:57   

Ok cool, then I guess the error message I got wasn't from that part simple_smile Here is the whole section which attempted to get a list of brokers to bind to the grid


    Quotit.DB.QUOTIT.HelperClasses.EntityCollection brokerList;
Quotit.DB.QUOTIT.DatabaseSpecific.DataAccessAdapter brokerAdapter;
IRelationPredicateBucket finalFilter;
IPredicate notAlreadyMappedFilter;
ISortExpression brokerSort;
ISortClause brokerCompanyNameSort;

brokerSort  = new SortExpression();
finalFilter = new RelationPredicateBucket();
brokerList  = new Quotit.DB.QUOTIT.HelperClasses.EntityCollection(
        new Quotit.DB.QUOTIT.FactoryClasses.BrokerEntityFactory());
brokerAdapter= new Quotit.DB.QUOTIT.DatabaseSpecific.DataAccessAdapter();           
notAlreadyMappedFilter  = new FieldCompareSetPredicate(
    Quotit.DB.QUOTIT.FactoryClasses.EntityFieldFactory.Create(BrokerFieldIndex.BrokerId),
    null,
    Quotit.DB.Admin.FactoryClasses.EntityFieldFactory.Create(CustomerIproAccountsImportFieldIndex.IproBrokerId),
    null,
    SetOperator.Exist,
    null,
    true);
brokerCompanyNameSort = Quotit.DB.QUOTIT.FactoryClasses.SortClauseFactory.Create(
    BrokerFieldIndex.CompanyName, 
    SortOperator.Ascending);    

brokerSort.Add(brokerCompanyNameSort);

finalFilter.PredicateExpression.Add(notAlreadyMappedFilter);
brokerAdapter.FetchEntityCollection(brokerList, finalFilter, 0, brokerSort);
m_oBrokerGrid.DataSource = brokerList;
m_oBrokerGrid.DataBind();   

The error message is:

[NullReferenceException: Object reference not set to an instance of an object.] Quotit.DB.QUOTIT.DatabaseSpecific.PersistenceInfoFactory.GetFieldPersistenceInfo(String objectName, String fieldName) in I:\Quotit\DB\Quotit\DatabaseSpecific\PersistenceInfoFactory.cs:101 Quotit.DB.QUOTIT.DatabaseSpecific.DataAccessAdapter.GetFieldPersistenceInfo(IEntityField2 field) in I:\Quotit\DB\Quotit\DatabaseSpecific\DataAccessAdapter.cs:270 Quotit.DB.QUOTIT.DatabaseSpecific.DataAccessAdapter.InsertPersistenceInfoObjects(IPredicateExpression expression) in I:\Quotit\DB\Quotit\DatabaseSpecific\DataAccessAdapter.cs:397 SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.InterpretFilterBucket(IRelationPredicateBucket filterBucket, Boolean& relationsPresent, IPredicateExpression& expressionToPass) SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Int32 pageNumber, Int32 pageSize) SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses) Quotit.Apps.Admin.WebForm1.BindData() in i:\quotit\apps\admin\customer\mapiproaccountsbulk.aspx.cs:120 Quotit.Apps.Admin.WebForm1.Page_Load(Object sender, EventArgs e) in i:\quotit\apps\admin\customer\mapiproaccountsbulk.aspx.cs:50 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain()

Am I missing something obvious?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Feb-2005 23:10:46   

Will look at it tomorrow morning(wednesday)

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-Feb-2005 11:13:24   

Please check if the database specific project is in sync with the database generic project. This problem often occurs if the database generic project is updated with new entities or an entity got a new field/field got renamed, and the persistence info in the database specific project doesn't have persistence info for that field, for these new entities etc.

Also, if you use 1 database generic project and multiple database specific projects, be sure the order of the fields and the names of the fields in an entity is/are the same in all database specific projects.

Frans Bouma | Lead developer LLBLGen Pro