i'm using h2 testing purposes, have problems when casting derived class. case is:
@entity @discriminatorcolumn(name = "dtype", discriminatortype = discriminatortype.string, length = 64) public class {...} @entity @discriminatorcolumn(name = "dtype", discriminatortype = discriminatortype.string, length = 64) public class b extends {...} my dataset looks like:
<a attr1=... attr2=... dtype="a"/> <b attr1=... attr2=... dtype="b"/> the problem when try query in jpa one:
query q = em.createquery("select a where..."); and try value this:
(b) q.getresultlist().get(0); i have following exception:
java.lang.classcastexception: mypackage.a cannot cast mypackage.b in mysql works fine, not in h2. h2 version: 1.3.171
assuming q.getresultlist() returns list of a objects,
b extends a , therefore, b can cast a. reverse not true. instance of a cannot cast b.
Comments
Post a Comment