Thought inc.

The Dynamic O/R Mapping Company
     

CocoBase Technical Support Forums
For access to developer site with software download and doc's, please request CocoBase download and password
will be emailed to you. Response to posts will appear when answered by THOUGHT Support team.
NOTE:You must register separately with forum in order to post your questions, please click on register icon below.
Home   Frequently Asked Questions   Search   Edit your profile   Registration is free!  
Email This Page to Someone!
Show a Printable Version
CocoBase Enterprise O/R Forums > CocoBase Questions
Please help me find this :)
< Previous Thread     Next Thread >
Author
Thread    Post New Thread     Post A Reply
neil_poska
Member

Registered: Mar 2006
Posts: 6

I can't find what I am looking for in the documentation, so if you could point me where to look, that would be great.

I have a complex SQL where clause (with a subselect and some DB specific syntax). I want to pass this SQL directly to cocobase for a non-ejb finder method. Something like:

String myWhereClause = "..... lots of junk... ";
Vector results = facade.load (MyObject, myWhereClause);

I would prefer to not use EJBQL because it looks like I need to set up a separate facade for it, and it doesn't look like CBQueryBuilder will allow me to do what I need.

Any suggestions?

03-16-2006 02:18 PM
Click Here to See the Profile for neil_poska    Find more posts by neil_poska        Edit/Delete Message    Reply w/Quote    IP: Logged
admin
Administrator

Registered: Apr 2001
Posts: 19

Hi,

Please refer to thought.CocoBase.CBQuery class java docs. CBQuery is the 'core' class of the cocobase dynamic querying system. It provides methods that allow to set a 'raw' sql where condition for the query, and even an entire sql where clause can be set. The only requirement is that you have a 'base' cocobase map that describes the objects you are querying against.

As for the facade, you need to use ejbql in order to have your objects being managed by it. Or what you can also do is to obtain a cursor (see thought.CocoBase.CBCursor) for that ejb-ql query and call facade.unload() on each object so it ceases to be managed you have collect it within your finder method. Another option is to subclass CBFacadeLocal so that you can create a CBQuery instance out of its internal CocoPowder dataSource handle.

Hope that helps!
THOUGHT Support

03-17-2006 08:04 AM
Click Here to See the Profile for admin    Find more posts by admin        Edit/Delete Message    Reply w/Quote    IP: Logged
neil_poska
Member

Registered: Mar 2006
Posts: 6

CBQuery seems to be what I am looking for.

One problem: Our code is based around CBFacades, and CBQuerys are built from CocoPowders. From the Programmers Guide and Javadoc, I don't see a way to get a CocoPowder from a facade or anything else I have started with.

Any pointers?

03-22-2006 09:58 AM
Click Here to See the Profile for neil_poska    Find more posts by neil_poska        Edit/Delete Message    Reply w/Quote    IP: Logged
admin
Administrator

Registered: Apr 2001
Posts: 19

Sure,

Basically the CBQueryBuilder is the high level SQL orientied builder, and EJBQL is the high level Query language. Most application queries can be issued with EJBQL which is built into the facade. For example:

Vector paramVector = new Vector();
paramVector.add(new Integer(1));
Vector v = cbf.executeQLQuery("select object(c) from com.mypkg.Customer c where c.id = ?1", paramVector);

The EJBQL syntax supports object model queries, and in cb4 you can find complex samples in the demos\pguide\ejbqlconsole folder EJBQL_examples.txt

If there's some query option that you can't implement with EJBQL, then the CBQueryBuilder/CBQuery interfaces can also be used. What you can do is implement a subclass of the CBFacade and produce customer queryies that share the same dataSource/Navigation system as the rest of the application model.

Check the EJBQL syntax first, and if there's something that requires a Query interface in the facade, let us know and we can assist you by sending you a prototype of how you can accomplish this.

THOUGHT Support

03-22-2006 12:44 PM
Click Here to See the Profile for admin    Find more posts by admin        Edit/Delete Message    Reply w/Quote    IP: Logged
All times are PST (US)    Post New Thread     Post A Reply
Forum Jump:
< Previous Thread     Next Thread >

Forum Rules:
Who Can Read The Forum? Any registered user or guest.
Who Can Post New Topics? Any registered user.
Who Can Post Replies? Any registered user.
Changes: Messages can be edited by their author. Messages can be deleted by their author.
Posts: HTML code is OFF. Smilies are OFF. vB code is OFF. [IMG] code is OFF.

Admin Options:
Open / Close Thread
Move Thread
Delete Thread
Edit Thread

< Contact Us - THOUGHT Inc. >

Copyright © Jelsoft Enterprises Limited 2000.
Copyright 2001 All Rights Reserved, THOUGHT Inc.