Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to customize the update query?
icon5.gif  How to customize the update query? [message #1065656] Thu, 27 June 2013 01:56 Go to next message
Oliver Zhou is currently offline Oliver ZhouFriend
Messages: 41
Registered: February 2012
Member
Hi,

I have a requirement that it required me to customize the update query generated automatically by EclipseLink.

Since the auto generated update query has only primary key expression in the where clause, in our case, we have a database proxy sitting in between the web application and the mysql database. It can redirect the sql statement to the specified database according to the value of partition key (which is a field of the updated object).

So I need to append this field to the where clause of the update statement.

How can I do that?

Best wishes,
Oliver
Re: How to customize the update query? [message #1066632 is a reply to message #1065656] Wed, 03 July 2013 14:03 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You can use a DescriptorCustomizer to set the SQL for the update query.

See,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/CRUDStoredProcedures

The example uses stored procedures, but you can also give SQL, for SQL parameters are defined by #<column-name>

i.e.
descriptor.getQueryManager().setUpdateSQLString("update employee set name=#name where id=#id and key=#key")

Also you may wish to investigate EclipseLink partitioning support,

http://wiki.eclipse.org/EclipseLink/Examples/JPA/Partitioning


James : Wiki : Book : Blog : Twitter
Previous Topic:EclipseLink RestService entityManager is null
Next Topic:Predeployment of PersistenceUnit [. . .] failed
Goto Forum:
  


Current Time: Thu Apr 25 09:31:42 GMT 2024

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

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

Back to the top