Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » ReadallQuery alias setting
icon5.gif  ReadallQuery alias setting [message #1058200] Mon, 13 May 2013 08:11 Go to next message
Omid Pourhadi is currently offline Omid PourhadiFriend
Messages: 13
Registered: May 2013
Junior Member
Hi,

I've written a query redirector code and after I change expressionbuilder, generated query alias is not recognized.

 ReadAllQuery readAllQuery = (ReadAllQuery) query;
        readAllQuery.setDoNotRedirect(true);
        readAllQuery.setReferenceClass(DocumentHelper.class);
        ExpressionBuilder docExp = new ExpressionBuilder(Document.class);
        ExpressionBuilder exp = new ExpressionBuilder(DocumentHelper.class);        
        readAllQuery.setExpressionBuilder(exp);
        return ((AbstractSession) session).executeQuery(readAllQuery, (AbstractRecord) arguments);


Error :

invalid reference to FROM-clause entry for table "cfs_document"
Hint: Perhaps you meant to reference the table alias "t0".

query : SELECT cfs_document.id, cfs_document.discriminator, cfs_document.created_at, cfs_document.created_by, cfs_document.deleted_at, cfs_document.deleted_by, cfs_document.name, cfs_document.size, cfs_document.owner_id, cfs_document.parent_id FROM cfs_document t0, documents t1 WHERE (t0.name = ?)


How can I replace a query with redirector ?
Re: ReadallQuery alias setting [message #1058616 is a reply to message #1058200] Tue, 14 May 2013 14:46 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Are you changing the redirected query? You should create a new query.

Also you are creating two ExpressionBuilders, but seem to only be using one.


James : Wiki : Book : Blog : Twitter
Re: ReadallQuery alias setting [message #1058989 is a reply to message #1058616] Thu, 16 May 2013 07:02 Go to previous messageGo to next message
Omid Pourhadi is currently offline Omid PourhadiFriend
Messages: 13
Registered: May 2013
Junior Member
thanks James for your reply.
Actually I want to have a field which is not in table but I'm creating it with a function so I want to replace original query with my query and also be able to filter query based on it.

My model class is :

@QueryRedirectors(readAll=DocumentQueryRedirector.class)
public class Document {

    @Column( name = "fullpath", insertable = false, updatable = false)
    private String fullPath; //this field is not available in database table and comes from sql function

}


function query is :

select * from fetch_children_of(1)


I'm looking for a solution to solve this issues :



  • be able to load relations by readallquery
  • be able to filter query based on fields which are not present in table
  • be able to replace my function with original query and return objects


PS : in above example I created another POJO (DocumentHelper) . it is exactly the same as Document and mapped it to a view. since I couldn't replace original query I tried to join them but I don't think it would be a good solution.
Re: ReadallQuery alias setting [message #1060022 is a reply to message #1058989] Wed, 22 May 2013 14:53 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You may want to look into using the @AdditionalCriteria to filter your table. You can use the COLUMN() operator in JPQL to query a non-mapped column.

James : Wiki : Book : Blog : Twitter
Previous Topic:NPE in DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:978)
Next Topic:Retry on closed Connection
Goto Forum:
  


Current Time: Tue Apr 23 13:12:33 GMT 2024

Powered by FUDForum. Page generated in 0.03028 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top