java hibernate:选择多态hql查询中的鉴别器列 [英] java hibernate: selecting the discriminator column in polymorphic hql query

查看:88
本文介绍了java hibernate:选择多态hql查询中的鉴别器列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在hibernate中,我想选择鉴别器值。类似于



从动物中选择鉴别符,ID,姓名,年龄



这个想法是将这个查询的结果发送到客户端,这样我就可以根据鉴别器列的值(即猫,狗,大象等)显示不同的图标。



这可能吗?

解决方案

您可以这样做:

 从动物中选择a.class,a.id,a.name,a.age a 

Hibernate文档


特殊属性类在多态持久性情况下访问实例的鉴别器值。



In hibernate, I want to select the discriminator value. Something like

select discriminator, id, name, age from Animal

The idea is to send the result of this query to the client side, so that I can display a different icon based on the value of the discriminator column (i.e. cat, dog, elephant, etc).

Is that possible? How?

解决方案

You can do it as follows:

select a.class, a.id, a.name, a.age from Animal a

From Hibernate Documentation:

The special property class accesses the discriminator value of an instance in the case of polymorphic persistence.

这篇关于java hibernate:选择多态hql查询中的鉴别器列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆