Hibernate version: 3.2.3 SP1
Hallo miteinander,
ich habe ein Problem mit einem NamedQuery. Und zwar läßt sich das Ergebnis beim Iterieren nicht casten.
Der NamedQuery:
Code:
@NamedQuery(name="allePersonenZuEinemMandanten",
query="SELECT p.id, p.name FROM Person p WHERE p.mandant.id = :mid")
Der Aufruf:
Code:
Session hibernateSession = HibernateKonfiguration.getSessionFactory().getCurrentSession();
Query hsql = hibernateSession.getNamedQuery("allePersonenZuEinemMandanten");
hsql.setParameter("mid", new Integer(mandantenID));
for(Iterator it = hsql.iterate(); it.hasNext();) {
Person einePerson = (Person) it.next();
tmpPerson.add(einePerson);
}
Ausschnit aus dem Stacktrace:
Code:
[java] Exception in thread "main" javax.ejb.EJBException: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to persistence.Person; nested exception is: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to persistence.Person
[java] java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to persistence.Person
[java] at sessionbeans.PersonenVerwaltungBean.allePersonenZuEinemMandanten(PersonenVerwaltungBean.java:80)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
[java] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
[java] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
[java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
[java] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
[java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
[java] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
[java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
[java] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
[java] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
[java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
[java] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
[java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
[java] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
[java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext
Ich hoffe mir kann das einer erklären. Vielen Dank
Role