toplink 在更新操作时为表添加 TL_ 前缀
我在 JPA (toplink) 上有非常简单的命名查询:
UPDATE Server s SET s.isECM = 0
我不携带已预加载实体的缓存或有效性。但数据库连接是从受限帐户执行的(仅限 INSERT/UPDATE/DELETE)。看起来这个查询上的toplink执行(并且由于TL_Server不存在而失败)非常奇怪的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]
这是什么?简单的UPDATE如何显示为INSERT?为什么toplink查询TL_?
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 INSERT/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_?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TL_Server 是一个临时表。由于 UpdateAll 查询被确定为复杂,因此必须使用临时表。我认为它很复杂,因为该类有多个表,因此必须将它们连接起来,而这不能通过简单的更新来完成。
如果您的班级只有一个表,那么只需进行简单的更新即可。
如果失败,则说明数据库平台的临时表支持存在问题。确保您正确设置“toplink.target-database”。你使用什么数据库?
您似乎使用的是非常旧版本的 TopLink Essentials?最新的 EclipseLink 版本中的 UpdateAll 支持已得到显着改进,您可以考虑升级。
如果您无法使用 TopLink Essentials 使其工作,您始终可以使用本机 SQL 查询而不是 JPQL。
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.