You get the exception when Roo tries to do the foreach on the depend collection
Code:
for (Zertifikatsart _zertifikatsart : depend) {
q.setParameter("depend_item" + dependIndex++, _zertifikatsart);
}
because depend contains the id's of your type, instead of the objects.
You can get through with it by doing something like this:
Code:
Set<Zertifikatsart> zertifikatsartSet= new HashSet<Zertifikatsart>();
String string = depend.toString().substring(1, depend.toString().length()-1);
String[] res = string.split(", ");
for(int i = 0; i < res.length; i++)
{
zertifikatsartSet.add(Zertifikatsart.findZertifikatsart(Long.parseLong(res[i])));
}
And where the foreach tries to iterate over depend, you replace it to iterate over your new Set containing the actual objects that you need.
Code:
for (Zertifikatsart _zertifikatsart : zertifikatsartSet) {
q.setParameter("depend_item" + dependIndex++, _zertifikatsart);
}
I hope that will help you and other, because I was myself in this situation.
P.S: maybe it's not 100% the methods you actually have that I wrote, so please review them again too work with your application

Originally Posted by
nimda
Hi there,
iīm just started using springroo to develop a web application tool and stuck on following problem:
Within the RooShell i added an attribute with the command field set, which referencing on itself. For that i also added an finder for the attribut and get some error i donīt know how to handle with?
RooEntity Class
Code:
@RooJavaBean
@RooToString
@RooPlural("Zertifikatsarten")
@RooEntity(finders = { "findZertifikatsartenByTitelLike",
"findZertifikatsartenByZertifikatskategorie",
"findZertifikatsartenByTitel", "findZertifikatsartenByDepend" })
public class Zertifikatsart {
.
.
.
@ManyToMany(cascade = CascadeType.ALL)
private Set<com.app.sample.domain.Zertifikatsart> depend = new HashSet<com.app.sample.domain.Zertifikatsart>();
// imported generated method for the finder functionality
public static TypedQuery<Zertifikatsart> findZertifikatsartenByDepend(
Set<Zertifikatsart> depend) {
if (depend == null)
throw new IllegalArgumentException("The depend argument is required");
EntityManager em = Zertifikatsart.entityManager();
StringBuilder queryBuilder = new StringBuilder(
"SELECT Zertifikatsart FROM Zertifikatsart AS zertifikatsart WHERE");
for (int i = 0; i < depend.size(); i++) {
if (i > 0)
queryBuilder.append(" AND");
queryBuilder.append(" :depend_item").append(i)
.append(" MEMBER OF zertifikatsart.depend");
}
TypedQuery<Zertifikatsart> q = em.createQuery(queryBuilder.toString(),
Zertifikatsart.class);
int dependIndex = 0;
for (Zertifikatsart _zertifikatsart : depend) {
q.setParameter("depend_item" + dependIndex++, _zertifikatsart);
}
return q;
}
}
ERROR Code:
Code:
java.lang.String cannot be cast to com.app.sample.domain.Zertifikatsart
Can anybody point me to the right way to think about this problem?
thx