Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
- new Unit().getBy(3L);
- @MappedSuperclass
- public abstract class Generic<T extends Generic> {
- @Transient
- public Class<T> entityClass;
- Generic() {
- entityClass = ((Class) ((Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]));
- }
- @Id
- @GeneratedValue(strategy = GenerationType.TABLE)
- public Long id;
- public T getBy(Long id) {
- return JPA.em().find(entityClass, id);
- }
- @MappedSuperclass
- public abstract class GenericDictionary<T extends Generic<T>> extends Generic<T> {
- @Required
- public String name;
- @Required
- public boolean active = true;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public boolean getActive() {
- return active;
- }
- public void setActive(boolean stat) {
- this.active = stat;
- }
- @Entity
- @Table(name="common__Unit")
- public class Unit extends GenericDictionary<Unit> {
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(name="parent_id")
- public Unit parent;
- }
- new Unit().getBy(3L);
- @Entity
- @Table(name="common__Clinic")
- public class Clinic extends GenericDictionary<Clinic> {
- @ManyToMany(cascade = CascadeType.PERSIST)
- public List<Unit> unit;
- Clinic clinic = new Clinic().getBy(3L);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement