私は方法がわからないNPEを取得しています、私はグーグルで周りを見回しました、そしてまともな答えを見つけることができないようです、plsを手伝ってくれる人は誰でも。スタックトレースが指しているCustomerDaoImpl行は次のとおりです。
return (CustomerPerk)this.sessionFactory.getCurrentSession().get(CustomerPerk.class, customerPerkPk);
java.lang.NullPointerException
at org.hibernate.type.EntityType.isEqual(EntityType.java:344)
at org.hibernate.type.ComponentType.isEqual(ComponentType.java:172)
at org.hibernate.engine.EntityKey.equals(EntityKey.java:119)
at java.util.HashMap.get(HashMap.java:305)
at org.hibernate.engine.StatefulPersistenceContext.getEntity(StatefulPersistenceContext.java:368)
at org.hibernate.impl.SessionImpl.getEntityUsingInterceptor(SessionImpl.java:656)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromSessionCache(DefaultLoadEventListener.java:533)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:440)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
at com.perkinator.dao.CustomerPerkDaoImpl.getCustomerPerk(CustomerPerkDaoImpl.java:32)
at com.perkinator.service.CustomerServiceImpl.addPerkAmount(CustomerServiceImpl.java:169)
CustomerPerkマッピング
@Entity
@Table(name = "customer_perk")
public class CustomerPerk {
@Id
private CustomerPerkPk customerPerkPK = new CustomerPerkPk();
@Column
private BigDecimal amountSpent;
@Column
private int timesVisited;
@SuppressWarnings("unused")
@Column(name="customer_id", nullable = false, insertable = false, updatable = false)
private int customer;
@SuppressWarnings("unused")
@Column(name = "perk_id", nullable = false, insertable = false, updatable = false)
private int perk;
そしてCustomerPerkPk
@Embeddable
public class CustomerPerkPk implements Serializable {
@ManyToOne
private Customer customer;
@ManyToOne
private Perk perk;