title: The class must be declared abstract error
body: <p>I am having trouble with generic abstract classes and multiple parameters. In brief, I have a database table with a composite key defined by ProductAttributeEntity.class and ProductAttributeEntityPk.class, where ProductAttributeEntityPk.class is the composite key. I am struggling to pass ProductAttributeEntityPk.class into the abstract class for the getById method, which gives me, “Class must either be declared abstract or implement abstract method” error.</p>
  <p>How can I get around this problem?</p>
  <p><strong>PS:</strong> I am <strong>new</strong> to java</p>
  <p>Abstract DAO class (<a href="https://pastebin.com/n2FBQCg2" rel="nofollow noreferrer">https://pastebin.com/n2FBQCg2</a>)</p>
  <pre><code>package com.beetlehand.model.dao;
  
  import javax.persistence.EntityManager;
  import javax.persistence.Persistence;
  import java.util.List;
  import java.util.Map;
  
  public abstract class AbstractDao&lt;T, S&gt; {
  
      protected EntityManager entityManager;
  
      public EntityManager getEntityManager() {
          if(this.entityManager == null) {
              this.entityManager = Persistence
                  .createEntityManagerFactory(&quot;NewPersistenceUnit&quot;)
                  .createEntityManager();
          }
  
          return this.entityManager;
      }
  
      public abstract T getById(S id);
      public abstract T getOneBy(Map&lt;String, Object&gt; params);
      public abstract List&lt;T&gt; getBy(String predicates, Map&lt;String, Object&gt; params);
      public abstract List&lt;T&gt; getBy(String predicates, Map&lt;String, Object&gt; params, String orderBy);
      public abstract List&lt;T&gt; getBy(String predicates, Map&lt;String, Object&gt; params, String orderBy
              , Integer limit);
      public abstract List&lt;T&gt; getBy(String predicates, Map&lt;String, Object&gt; params, String orderBy
              , Integer limit, Integer offset);
  
      public abstract Long count();
      public abstract Long countBy(String predicates, Map&lt;String, Object&gt; params);
  }
  </code></pre>
  <p>DAO class (<a href="https://pastebin.com/tkMYLVZE" rel="nofollow noreferrer">https://pastebin.com/tkMYLVZE</a>)</p>
  <pre><code>package com.beetlehand.model.dao;
  
  import com.beetlehand.model.ProductAttributeEntity;
  import com.beetlehand.model.ProductAttributeEntityPk;
  import org.apache.commons.lang3.StringUtils;
  
  import javax.persistence.EntityManager;
  import javax.persistence.Persistence;
  import javax.persistence.TypedQuery;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Map;
  
  public class ProductAttributeDao extends AbstractDao&lt;ProductAttributeEntity, ProductAttributeEntityPk&gt; {
  
      public ProductAttributeEntity getById(ProductAttributeEntityPk id) {
          if (id == null) return null;
          return getEntityManager().find(ProductAttributeEntity.class, id);
      }
      
      /** other methods implementation **/
  
  }
  </code></pre>
  <p>Entity classes (<a href="https://pastebin.com/5YySBt7X" rel="nofollow noreferrer">https://pastebin.com/5YySBt7X</a>, <a href="https://pastebin.com/8rwD4kec" rel="nofollow noreferrer">https://pastebin.com/8rwD4kec</a>)</p>
  <pre><code>package com.beetlehand.model;
  
  import javax.persistence.*;
  
  @Entity
  @Table(name = &quot;product_attribute&quot;, schema = &quot;beetlehand&quot;, catalog = &quot;&quot;)
  @IdClass(ProductAttributeEntityPK.class)
  public class ProductAttributeEntity {
      private int productId;
      private int attributeValueId;
  
  /** getter, setters, equals and hashcode implementation **/
  
  }
  
  
  package com.beetlehand.model;
  
  import javax.persistence.Column;
  import javax.persistence.Id;
  import java.io.Serializable;
  
  public class ProductAttributeEntityPK implements Serializable {
      private int productId;
      private int attributeValueId;
  
  /** getter, setters, equals and hashcode implementation **/
  }
  </code></pre>