-->
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: ternary mapping, java iterator, classcasting exception
PostPosted: Wed Jun 09, 2010 7:00 am 
Newbie

Joined: Wed Jun 09, 2010 6:47 am
Posts: 1
Hello everyone,

I've reverse engineered a class using eclipse's plugin.

The result are the following files:

hbm.xml: http://dpaste.com/205097/
java class: http://dpaste.com/205111/
java class: http://dpaste.com/205113/ (btw, why does hibernate create this class too?)

When getting a List by:

List utpList = session.createCriteria(UsuarioTerritorioPerfil.class).setProjection(
Projections.projectionList()
.add(Projections.property("territorio"))
.add(Projections.property("perfil"))
).add(Restrictions.eq("usuario",user)).list();
}catch (SQLGrammarException e) {

this.setMsg("Criteria Error: " + e.getSQL());
return msg;
}
I get the classcast exception when iterating through the elements:

java.util.Iterator<UsuarioTerritorioPerfil> i = utpList.iterator();
JSONObject u = new JSONObject();
//UsuarioTerritorioPerfil utp;
while (i.hasNext()){
try {
/*
* Long t=i.next().getTerritorio().getId(); Can't do this, ClassCastException!
* i.next() is an instance of Object and cannot cast it...
*/

u.put("id", user.getId());
u.put("territory","t");
u.put("profile","p");
objectList.put(u);

i.next();


}
catch (Exception e) {
e.printStackTrace();
this.setMsg("JSON Error: " + e);
return msg;
}

}

This only happens on the class with a ternary mapping (I can do the same with other classes, all castings are ok).

Any hints / ideas why this casting is generating an error?

JSON Error: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.ngeografics.entities.UsuarioTerritorioPerfil

greetings,

Genis


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.