My class implements interface with methods. which arent implemented but no errors

116 views Asked by At

I've created dao class that implements an interface with two methods. None of them are implemented in that dao class. I am getting no errors. Everything compiles and works.

What am I doing wrong?

Here's my dao class:

package com.derp.generic.dao;

import javax.persistence.MappedSuperclass;
import org.springframework.stereotype.Repository;

import com.derp.generic.model.GenericDictionaryModel;

@Repository
@MappedSuperclass
public abstract class GenericDictionaryModelDaoImpl <T extends GenericDictionaryModel<?>> extends GenericModelDaoImpl implements GenericDictionaryModelDao {
}

And here's my interface:

package com.derp.generic.dao;

public interface GenericDictionaryModelDao<T> extends GenericModelDao<T>{
    public T getByName(String name);
    public T getByActive(boolean active);
}

REST OF CLASSESS:

package com.derp.generic.dao;

import java.util.List;

public interface GenericModelDao<T> {
    public void add(T entityClass);
    public void update(T entityClass);
    public void delete(long id);
    public T get(long id);
    public List<T> get();
    public String toString();
}

package com.derp.generic.model;

import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class GenericDictionaryModel<T extends GenericDictionaryModel<?>> extends GenericModel<T> {
    private String name;
    private boolean active;

    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;}
}

package com.derp.generic.model;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class GenericModel<T extends GenericModel<?>> {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    public long getId() {return id;}
    public void setId(long id) {this.id = id;}

}
1

There are 1 answers

0
Eran On BEST ANSWER

Your GenericDictionaryModelDaoImpl class is abstract, so it doesn't have to implement all the methods of the GenericDictionaryModelDao interface. Any concrete class that will inherit from your abstract class would have to implement all the unimplemented methods of that interface.