开发者

toplink prefixes table with TL_ while update operation

开发者 https://www.devze.com 2023-02-03 05:47 出处:网络
I have very simple named query on JPA (toplink ): UPDATE Server s SET s.isECM = 0 I don\'t carry about cache or validity of already preloaded entities. But database connection is performed from res

I have very simple named query on JPA (toplink ):

UPDATE Server s SET s.isECM = 0

I don't carry about cache or validity of already preloaded entities. But database connection is performed from restricted account (only INSER开发者_如何学JAVAT/UPDATE/DELETE). It is appeared that toplink on this query executes (and failed since TL_Server is not exists) very strange SQL:

INSERT INTO TL_Server (elementId, IsECM) 
    SELECT t0.ElementId, ? 
    FROM Element t0, Server t1 
    WHERE ((t1.elementId = t0.ElementId) AND (t0.elementType = ?))

bind => [0, Server]

What is this? How the simple UPDATE appears an INSERT? Why toplink queries TL_?


The TL_Server is a temp table. Because the UpdateAll query is determined to be complex the temp table must be used. I assume it is determined to be complex because the class has multiple tables, so they must be joined, which cannot be done on a simple update.

If you class just had a single table, then just a simple update would be done.

If this is failing, then it is an issue with your database platform's temp table support. Ensure you are setting you "toplink.target-database" correctly. What database are you using?

You seem to be using a very old version of TopLink Essentials? The UpdateAll support has considerably improved in the latest EclipseLink versions, you may consider upgrading.

If you cannot get it to work using TopLink Essentials, you could always just use a native SQL query instead of JPQL.

0

精彩评论

暂无评论...
验证码 换一张
取 消