Oracle TopLink:错误地获取重复记录
我使用 oracle TopLink 作为持久层,业务逻辑用 java 实现。 我正在使用表达式和表达式生成器类从数据库获取数据。 问题是,在数据库表中,我们没有重复的行,但是当我通过 ReadObjectQuery 类查询数据库时,我收到的行数与数据库表中的行数相同,但每次都会重复第一条记录,以便所有行都显示第一条记录。
请尽快帮助我
I am using oracle TopLink as a persistence layer with business logic implemented in java.
I am using expression and expression builder class to get data from database.
Problem is that in database table we donot have duplicate rows but when I query the database via ReadObjectQuery class I receive same quantity of rows as in database table but with first record duplicated each time such that all the rows show the first record.
Please help me as soon as possible
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在映射中定义的主键字段根本不唯一,则通常会出现此行为。 所发生的情况是,Toplink 检索第一行并将其转换为 Java 对象。 对于连续的行,定义的主键字段似乎与第一行中的主键字段相同。 因此,Toplink 不会再次进行转换,而是从其缓存中加载具有相同键的对象,即与第一行相关的对象。
This behavior normally shows up, if the primary key fields that you've defined in your mapping aren't unique at all. What happens is, that Toplink retrieves the first row and converts it to a Java object. For the consecutive rows it seems that the defined primary key field is identical to the one from the first row. Therefore Toplink doesn't do the conversion again and loads the object with the same key from its cache, i.e. the object relating to the first row.