阻止 Hibernate 尝试从数据库获取计算字段
我有一个已计算的业务对象的属性。该计算涉及一些登录用户的详细信息,因此不能表示为简单的 SQL 查询。
我在表示 Hibernate 映射 XML 文件中的字段时遇到问题,因为 Hibernate 继续尝试从数据库中检索该字段,尽管没有该名称的列。
I have a property of a business object which is calculated. The calculation involves some of the logged in user's details, and so can't be represented as a simple SQL query.
I'm having trouble representing the field in the Hibernate mapping XML file, because Hibernate continues to try and retrieve the field from the database, although there is no column by that name.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可能遗漏了一些明显的东西但是......那么你为什么要映射这个字段呢?但以防万一,这可能是
属性。我怀疑类似的事情,但我想得到确认。我认为你在这里没有那么多选择:要么使用
(无论是一个“愚蠢”的公式只是为了欺骗休眠)还是 返回非托管实体。I'm probably missing something obvious but... why are you mapping this field then? But just in case, this might be a good use case for a
<formula>
attribute.I was suspecting something like this but I wanted to get confirmation. I don't think you have that many options here: either use a
<formula>
(be it a "dumb" formula just to trick hibernate) or return a non managed entity.听起来你希望这个属性是“暂时的”
It sounds like you want this property to be "transient"