Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » DescriptorQueryManager+EntityManager(does it work?)
DescriptorQueryManager+EntityManager [message #734288] Fri, 07 October 2011 11:38 Go to next message
Neikius Mising name is currently offline Neikius Mising nameFriend
Messages: 43
Registered: April 2011

I have a bit of a special case here. I have to access all my data through stored procedures. I have read lots of stuff about DescriptorCustomizer and DescriptorQueryManager. But do they apply at all if I use EntityManager? I got the feeling they do not.

What I have so far:
* entity
* @NamedStoredProcedureQuery for one selectall procedure that returns a cursor (hopefully this part is ok, but got no errors)
* @Customizer points to the DescriptorCustomizer
* DescriptorCustomizer.customize function sets DescriptorQueryManager.setReadAllQuery() to an instance of namedQuery. I get the named query from @PersistenceContext injected EntityManager.

I am quite sure the named procedure never gets called (I put a where clause to the sql which returns a cursor, but I get the full table).

I am sure something is wrong, but the question here is - should this approach work at all? Am I basically wrong in some assumption and this cannot be made to work anyway or maybe this should work somehow and I am just erring somewhere.

Anyway, I gotta figure this out soon. Or I guess I will be calling sql the usual jdbc way as I did all my life... and writing my own caching and stuff.

Thanks for any information regarding this.

And btw, eclipselink sessions seem quite arcane to me. Also that workbench is strange and illogical. Guess some artifact from Toplink or what? I don't want to have too much xml configs anyway since I like the new way with annotations much better.
Re: DescriptorQueryManager+EntityManager [message #735350 is a reply to message #734288] Tue, 11 October 2011 15:14 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Yes, custom queries are used from JPA.

The descriptor defines basic CRUD operations that you can override using stored procedures or custom SQL. You need to set the query to a custom query, not a named query.

The basic CRUD operations only override very specific operations, not any dynamic or JPQL queries. For a specific query, you need to define a NamedStoredProcedureQuery for it and call that specific named query through JPA the same as calling any other named query.


James : Wiki : Book : Blog : Twitter
Re: DescriptorQueryManager+EntityManager [message #743335 is a reply to message #735350] Fri, 21 October 2011 11:10 Go to previous message
Neikius Mising name is currently offline Neikius Mising nameFriend
Messages: 43
Registered: April 2011
Yep, that link.

It doesn't work. At all. Tried a lot of scenarios and the queries from example never get called when using EntityManager.

I got ReadAllQuery working when using Session. But I don't want to use Sessions, too confusing and proprietary.

I guess I am defaulting to named queries as it seems the only possible alternative. Maybe you should just remove that wiki section since nothing seems to work as suggested? Also I am not filing bugs, don't have time. And I would probably get "not supported" answer anyway.

Something from the log:
FINER: client acquired: 26365814
FINER: TX binding to tx mgr, status=STATUS_ACTIVE
FINER: acquire unit of work: 18985130
FINEST: persist() operation called on: package.DataObject@6767df.
FINER: begin unit of work flush
FINER: TX beginTransaction, status=STATUS_ACTIVE
FINEST: Execute query InsertObjectQuery(package.DataObject@6767df)
FINEST: Execute query InsertObjectQuery(package.DataObject@6767df)
FINER: end unit of work flush
FINER: resume unit of work
FINER: TX beforeCompletion callback, status=STATUS_ACTIVE
FINER: begin unit of work commit
FINER: TX afterCompletion callback, status=COMMITTED
FINER: end unit of work commit
FINER: release unit of work
FINER: client released

Usually you would get sth like this:
FINEST: Execute query ReadAllQuery(name="DataObject.allrows" referenceClass=DataObject )
FINEST: Connection acquired from connection pool [default].
FINEST: reconnecting to external connection pool
	bind => [2 parameters bound]

calling a named query in this case.

Persist as you can see just does nothing. Hence I am just guessing that DescriptorCustomizer is not coupled with jpa part of the implementation at all. I would suppose fixing the docs wouldn't hurt. Might save some poor sods some time.
Previous Topic:Add Server Admin panel in own RCP Application
Next Topic:@Array doesn't seem to support basic types
Goto Forum:

Current Time: Thu Jun 21 10:45:38 GMT 2018

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

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

Back to the top