Hi everybody:
I have this
<?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 package="de.laliluna.example">
<class name="book" table="book">
<composite-id>
<key-property name="id" />
<key-many-to-one name="customer" column="customer_fk" class="de.laliluna.hibernate.customer" />
</composite-id>
<property name="title" column="title" type="java.lang.String" />
<property name="author" column="author" type="java.lang.String" />
<property name="available" column="available"/>
</class>
<query name="query_user"><![CDATA[from book, de.laliluna.hibernate.customer]]></query>
</hibernate-mapping>
And my class:
try
{
Session session = InitSessionFactory.getInstance().getCurrentSession();
Transaction tx = session.beginTransaction();
Query auth = session.getNamedQuery("query_user");
List res = auth.list();
Iterator iter = res.iterator();
if(iter.hasNext() )
{
book val = (book)iter.next();
//System.out.print(val.getauthor());
//book val = (book)iterex.next();
}
}
and i gotting this error
Exception in thread main
java.lang.ClassCastException: [Ljava.lang.Object;
at de.laliluna.example.TestExample.search(TestExample.java:153)
at de.laliluna.example.TestExample.main(TestExample.java:49)
How can i fix this problem?
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: