-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: size() collection not working in HQL
PostPosted: Sat Nov 28, 2009 4:12 am 
Newbie

Joined: Thu Sep 24, 2009 11:49 am
Posts: 8
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="contact.Insurance" table="InsuranceDetails">
<id name="id">
<generator class="assigned"/>
</id>
<property name="name">
<column name="insurance_name"/>
</property>

<property name="amt">
<column name="invested_amount"/>
</property>
</class>
</hibernate-mapping>


-----------------------------------------------------------

package contact;
public class Insurance
{
private int id;
private String name;
private int amt;

public Insurance(){}

public void setId(int id)
{
this.id = id;
}
public void setName(String name)
{
this.name = name;
}
public void setAmt(int amt)
{
this.amt = amt;
}
public int getId()
{
return this.id;
}
public String getName()
{
return this.name;
}
public int getAmt()
{
return this.amt;
}
}


-------------------------------------------------------------


package contact;
import org.hibernate.*;
import org.hibernate.cfg.*;
import java.util.*;

public class FromClauseDemo
{
public static void main(String args[])
{
Session session = null;
SessionFactory factory = null;

try
{
factory = new Configuration().configure().buildSessionFactory();
session = factory.openSession();
String sql = "select ins.id,ins.name,ins.amt from Insurance ins where size(ins.amt) >=2";
Query q = session.createQuery(sql);
List l = q.list();
Iterator i = l.iterator();
Display(i);
session.close();



}
catch(Exception e)
{
System.out.println(e.toString());
}
}

static void Display(Iterator i)
{
while(i.hasNext())
{
Object []o = (Object[])i.next();
System.out.print(o[0]);
System.out.print("\t" +o[1]);
System.out.println("\t" +o[2]);
}
}
}

-----------------------------------

size Collection not working getting this error:

[java] org.hibernate.QueryException: could not resolve property: size of: c
ontact.Insurance [select ins.id,ins.name,ins.amt from contact.Insurance ins wher
e size(ins.amt) >=2]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.