After the select I canĀ“t use the objects in list, if I cast to Subscription or SubscriptionPK class the ClassCastException is thrown, how to fix this?
Code:
List<Subscription> subscriptions =
em.createQuery("select s from Subscription s WHERE s.subscriptionPK.msisdn = :param").
setParameter("param", msisdn).
getResultList();
My entity class:
Code:
@Entity
@Table(name = "SUBSCRIPTION")
public class Subscription implements Serializable {
@EmbeddedId
protected SubscriptionPK subscriptionPK;
@Column(name = "DATE_INI")
private Date dateInit;
...
}
Code:
@Embeddable
public class SubscriptionPK implements Serializable {
@Basic(optional = false)
@Column(name = "id")
private String id;
@Basic(optional = false)
@Column(name = "APP_ID")
private long appId;
...
}