• Post Reply Bookmark Topic Watch Topic
  • New Topic

View mapping and query in Hibernate  RSS feed

J Chung
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a mapping of a view similar to the following:

<class name="ABCDEF" table="ABCDEF_VW" mutable="false">

<key-property name="A" column="A" type="String" />
<key-property name="B" column="B" type="String" />
<key-property name="C" column="C" type="String" />

<property name="D" column="D" type="String" not-null="true" />
<property name="E" column="E" type="String" not-null="true" />
<property name="F" column="F" type="String" not-null="true" />


I'm trying to run the following query:

select distinct B, D from ABCDEF_VW where A = ? order by 2

In my Hibernate DAO class I'm trying to implement the above query with:

List resultList = null;
try {
resultList = session.createCriteria(ABCDEFView.class)
.add(Restrictions.eq("A", strA))
catch (HibernateException ex) {

The above code always results in the list resultList being empty.

I'd appreciate any insight into what I'm doing wrong and how to code the desired query.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!