Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » How to customize the update query?
icon5.gif  How to customize the update query? [message #1065656] Wed, 26 June 2013 21:56 Go to next message
Eclipse UserFriend
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 10:03 Go to previous message
Eclipse UserFriend
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
Previous Topic:EclipseLink RestService entityManager is null
Next Topic:Predeployment of PersistenceUnit [. . .] failed
Goto Forum:
  


Current Time: Fri Jul 04 19:24:42 EDT 2025

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

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

Back to the top